我在 Scalarium 上使用 Chef下载代理并在其上运行各种命令。我正在尝试的是在配方中编写一个 shell 脚本来执行此操作。
file "/etc/profile.d/blah.sh" do
content <<-EOH
sudo -sH
<Retrieve file and run some commands>
EOH
end
当我在 Scalarium 中运行配方时,没有发生错误,但命令也没有运行。命令本身没有错误,因为我已经在我的计算机上运行了它们。
配方肯定被阅读了,因为 Chef 日志包含 blah.localdomain 上的处理文件[/etc/profile.d/blah.sh]
。
我以前从未使用过 Chef,我是否需要做其他事情来告诉它执行 shell 脚本?
最佳答案
也许你想要这样的东西:
file "/etc/profile.d/blah.sh" do
mode 0500
content <<-EOH
sudo -sH
<Retrieve file and run some commands>
EOH
end
execute "/etc/profile.d/blah.sh"
或者,您可以将文件检索和命令运行直接放入您的 Chef Recipe 中:
remote_file "/path/to/where/the/file/should/be/saved" do
source "https://example.com/path/to/where/the/file/comes/from"
end
execute "first command"
execute "second command"
关于ruby - Chef shell 脚本未运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7348541/