厨师在厨师食谱中打印出命令 运行 的输出

Chef print out output of command ran in chef recipe

我有一个厨师食谱需要修改,我只想看看命令的输出。

bash 'Execute my script' do
  user 'root'
  cwd  '/'
  code <<-EOH
    cmd_stdout=$(echo 'hi')
    echo $cmd_stdout
  EOH
end

当我收敛我的厨师厨房时,此脚本运行。我只是没有看到任何输出。在这种情况下,查看 "hi" 的最佳方式是什么?

我建议使用 execute 并将 live_stream 设置为 true。它将类似于以下内容:

execute 'apache_configtest' do
  command <<-EOH
    cmd_stdout=$(echo 'hi')
    echo $cmd_stdout
  EOH
  live_stream true
end