How can I set the log output level for Chef on Amazon OpsWorks?

风流意气都作罢 提交于 2019-12-05 02:37:41

问题


My question is similar to: How can I display the output of a Opscode Chef bash command in my console?

I want to be able to see console output for my running recipe. In particular, my recipe failed to start JBoss because JAVA_HOME was not being set. It took me an entire day to figure this out because the statement JAVA_HOME is undefined was not being printed to the Chef output. When running chef solo, debugging output can be turned on by appending -l debug to the command, as in: chef-solo -c solo.rb -j node.json -l debug

However, when using Amazon OpsWorks, there is no such option:

sudo opsworks-agent-cli run_command [activity] [date] [/path/to/valid/json.file]

How can I add a log level to run_command?


回答1:


Try running:

cd /opt/aws/opsworks/current
bundle exec chef-solo -l debug -c conf/solo.rb -j /var/lib/aws/opsworks/chef/XXX.json



回答2:


source: http://docs.aws.amazon.com/opsworks/latest/userguide/troubleshoot.html

Each Chef run produces a log, which provides a detailed description of the run and is a valuable troubleshooting resource. To specify the amount of detail in the log, add a Chef::Log.level statement to a custom recipe that specifies the desired log level. The default value is :info. The following example shows how to set the Chef log level to :debug, which provides the most detailed description of the run.

Chef::Log.level = :debug

In your recipe, add the following

require 'chef/log'
Chef::Log.level = :debug
...

You can also control the log using the custom_json property in stack setting.

{"opsworks":{"chef_log_level":"debug"}}

The above turns on debug for chef and opsworks, but does not yet show the output of the commands you might run using bash or other script.



来源:https://stackoverflow.com/questions/18598920/how-can-i-set-the-log-output-level-for-chef-on-amazon-opsworks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!