0
私たちのノードではシェフクライアントがスケジュールされていますので、チャットでエラーが報告されるように例外処理を設定したいと思います。 シェフ例外処理 - > chat_message(LWRP)を使用する最も簡単な方法:run_failed
は、以前私が、私はLWRPchat_message
で例外を報告する
シンプルな方法をしたいと思い、私のレシピ
deploy_stuff
で、今
chat_message do
message "Hello, World"
channel "deployments"
end
をチャットに投稿LWRPを書くためにここに役立つなった、と私はみましたこの:
# 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_message
を呼び出すレシピの他のコードが正常に機能するので、chat
料理の本が含まれていることを確信しています。
ライブラリメソッドはDSLを使用できますか? 'chat_message'は' execute do \ n command "curl ....を使います。\ n end' – vikingsteve
いいえ、あなたはDSLからプレーンなRubyを呼び出すことができますが、その逆はできません。 – coderanger
chef :: httpクライアントAPIを使用する必要があります。 – coderanger