【问题标题】:Chef: How I get file content to a variable ,but file do not exist yet厨师:我如何将文件内容获取到变量中,但文件尚不存在
【发布时间】:2017-12-19 22:32:56
【问题描述】:

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

     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

【问题讨论】:

    标签: ruby chef-infra chef-recipe recipe


    【解决方案1】:

    问题在于 Chef 的两遍模型,我在 https://coderanger.net/two-pass/ 中对此进行了详细说明。不幸的是,您在这里没有提供足够的细节来建议具体的解决方案,但大致上您需要将 shell_out!() 调用移到编译时未评估的地方。

    【讨论】:

      猜你喜欢
      • 2015-08-18
      • 2023-03-27
      • 1970-01-01
      • 1970-01-01
      • 2016-08-19
      • 1970-01-01
      • 2015-01-15
      • 2015-03-30
      • 1970-01-01
      相关资源
      最近更新 更多