我需要在我将创建的文件中获取文件内容。 我的代码:
execute "foo" do
command "echo "Hello World > /tmp/foo"
action :run
end
variable = shell_out!("cat /tmp/foo").stdout
ERRO
ERROR: Expected process to exit with [0], but received '1'
---- Begin output of cat /tmp/foo ----
STDOUT:
STDERR: cat: /tmp/foo: No such file or directory
---- End output of cat /tmp/foo ----
Ran cat /tmp/data.uuid returned 1
答案 0 :(得分:0)
问题是Chef的双遍模型,我在https://coderanger.net/two-pass/中详述了该模型。遗憾的是,您没有提供足够的详细信息来建议特定的解决方案,但大致需要将shell_out!()
调用移动到编译时未评估的地方。