Question

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?

Was it helpful?

Solution 2

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top