gpt4 book ai didi

ruby - Chef shell 脚本未运行

转载 作者:数据小太阳 更新时间:2023-10-29 08:05:52 25 4
gpt4 key购买 nike

我在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com