Ruby Chef:如何将文件内容添加到变量,但文件还不存在

Ruby Chef:如何将文件内容添加到变量,但文件还不存在,ruby,chef-infra,chef-recipe,recipe,Ruby,Chef Infra,Chef Recipe,Recipe,我需要在我将创建的文件中获取文件内容。 我的代码: execute "foo" do command "echo "Hello World > /tmp/foo" action :run end variable = shell_out!("cat /tmp/foo").stdout 错误 ERROR: Expected process to exit with [0], but received '1' ---- Begin outpu

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

     execute "foo" do
         command "echo "Hello World > /tmp/foo"
         action :run 
end

variable = shell_out!("cat /tmp/foo").stdout
错误

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

问题是Chef的双通道模型,我将详细介绍它。不幸的是,您在这里没有提供足够的详细信息来建议具体的解决方案,但大致上您需要将
shell\u移出!()
调用到编译时未计算的地方