Chef:我如何获取变量的文件内容,但文件还不存在

时间:2017-07-14 18:24:03

标签: ruby chef chef-recipe recipe

我需要在我将创建的文件中获取文件内容。 我的代码:

     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

1 个答案:

答案 0 :(得分:0)

问题是Chef的双遍模型,我在https://coderanger.net/two-pass/中详述了该模型。遗憾的是,您没有提供足够的详细信息来建议特定的解决方案,但大致需要将shell_out!()调用移动到编译时未评估的地方。