【发布时间】:2016-10-14 17:28:12
【问题描述】:
我们在节点上安排了 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 的其他代码可以正常工作。
【问题讨论】:
标签: exception-handling chef-infra chef-recipe lwrp