Nai*_*aba 3 chef-infra aws-opsworks
我的问题类似于:如何在控制台中显示Opscode Chef bash命令的输出?
我希望能够看到我正在运行的食谱的控制台输出.特别是,我的配方未能启动JBoss,因为JAVA_HOME没有设置.我花了整整一天的时间才弄明白,因为声明JAVA_HOME is undefined没有打印到Chef输出.运行chef solo时,可以通过附加-l debug命令打开调试输出,如下所示:chef-solo -c solo.rb -j node.json -l debug
但是,在使用Amazon OpsWorks时,没有这样的选项:
sudo opsworks-agent-cli run_command [activity] [date] [/path/to/valid/json.file]
Run Code Online (Sandbox Code Playgroud)
如何添加日志级别run_command?
来源:http://docs.aws.amazon.com/opsworks/latest/userguide/troubleshoot.html
每个Chef运行生成一个日志,该日志提供运行的详细描述,是一个有价值的故障排除资源.要指定日志中的详细信息量,请将Chef :: Log.level语句添加到指定所需日志级别的自定义配方中.默认值为:info.以下示例显示如何将Chef日志级别设置为:debug,它提供运行的最详细描述.
Chef::Log.level = :debug
Run Code Online (Sandbox Code Playgroud)
在您的食谱中,添加以下内容
require 'chef/log'
Chef::Log.level = :debug
...
Run Code Online (Sandbox Code Playgroud)
您还可以使用堆栈设置中的custom_json属性来控制日志.
{"opsworks":{"chef_log_level":"debug"}}
Run Code Online (Sandbox Code Playgroud)
上面打开了chef和opsworks的debug,但是还没有显示你可能使用bash或其他脚本运行的命令的输出.