我们在节点上安排了 chef-client,我想设置异常处理,以便在我们的聊天中报告错误。
以前我在这里得到帮助来写一个 LWRP 来聊天
chat_message do
message "Hello, World"
channel "deployments"
end
现在,在我的食谱deploy_stuff
中,我想要一种使用 LWRP 报告异常的简单chat_message
方法,我尝试了这个:
# set up error handler
Chef.event_handler do
on :run_failed do |exception|
chat_message ":exclamation: chef run_failed on #{Chef.run_context.node.name}: #{exception.message}"
end
end
但是它没有用:
Running handlers:
[2016-10-14T10:13:48+02:00] ERROR: Running exception handlers
Running handlers complete
[2016-10-14T10:13:48+02:00] ERROR: Exception handlers complete
Chef Client failed. 10 resources updated in 20 seconds
[2016-10-14T10:13:48+02:00] ERROR: undefined method `chat_message' for #<#<Class:0x00000005e1ef60>:0x00000005e1ee70>
[2016-10-14T10:13:48+02:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
什么undefined method chat_message
意思 - 我不能在这里使用 LWRP 吗?
我确信chat
食谱包括在内,因为我的食谱调用中的其他代码chat_message
工作正常。