如何在厨师中运行bash脚本文件?

jmv*_*bxx 10 bash file chef-infra

我写了一个简短的bash脚本并将其存储起来files/default/bash.sh.

如何链接它以使其在我的主要默认配方中运行?它需要以sudo身份运行,因为我使用的是ubuntu系统.

jmv*_*bxx 14

经过高低搜索后我终于找到了答案:

cookbook_file "/tmp/lib-installer.sh" do
  source "lib-installer.sh"
  mode 0755
end

execute "install my lib" do
  command "sh /tmp/lib-installer.sh"
end
Run Code Online (Sandbox Code Playgroud)

感谢这个链接!