3

我在Scalarium上使用 Chef来下载代理并在其上运行各种命令。我正在尝试在配方中编写一个 shell 脚本来执行此操作。

file "/etc/profile.d/blah.sh" do
  content <<-EOH
sudo -sH
<Retrieve file and run some commands>
  EOH
end

当我在 Scalarium 中运行配方时,没有发生错误,但命令也没有运行。命令本身没有错误,因为我已经在我的计算机上运行了它们。

食谱肯定是读过的,因为厨师日志包含Processing file[/etc/profile.d/blah.sh] on blah.localdomain.

我以前从未使用过 Chef,我需要做其他事情来告诉它执行 shell 脚本吗?

4

1 回答 1

2

也许你想要类似的东西:

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"

或者,您可以将文件检索和命令运行直接放入您的厨师食谱中:

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"
于 2011-09-08T13:24:33.597 回答