Vagrant - how to print Chef's command output to stdout?

大兔子大兔子 提交于 2019-12-04 08:40:51

I know nothing about vagrant but I think this may relate to your issue... Happy to delete this answer if proves to be irrelevant!

--force-formatter

Indicates that formatter output will be used instead of logger output.

So I found if solo.rb has log_location defined adding the option --force-formatter displays the output when running chef via rundeck or remotely executing ssh user@host "chef-solo --force-formatter"

It prints bash/script/execute resource execution output to stdout only when:

  • You need TTY for your remote chef-solo/chef-client command.
  • not run chef-client in daemon mode
  • chef log level is set to :debug

See the code chef/Mixin/ShellOut, line 36.

When using vagrant up, it seems no option to provide a TTY for the ssh session, so the solution is kind of walk around after you set :debug log level for chef:

  1. run $ vagrant up
  2. run $ vagrant ssh -- -t - which means it passes -t to ssh command so that there's a tty for the ssh session.
  3. run chef-solo to manually run chef, then you will get output on stdout.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!