ResourcesのNotificationsについて
未だキータイプしたほうが早いよねーと思って、急ぎの時はレシピを書かずに手でconfigureして後で後悔する脳筋です。
早く料理人になりたい。
td-agentのrecipeを眺めていた時にsubscribeが利用されており「?」となったのでメモ。
Resourcesで利用されるnotifiesとsubscribeについて
まずはgoogle翻訳してみた。
notifies:Notify another resource to take an action if this resource changes state for any reason.
↓
このリソースの状態が何らかの理由で変更された場合、アクションを実行する別のリソースに通知します。
どうやらブッ殺すって思った時に行動を起こすらしい。プロシュート兄貴に怒られるマンモーニ属性ですね。
httpd.conf書き換えたらapache再起動のように、リソース実行順序の関連付けができます。
さて次,subscribes
subscribes:Take action on this resource if another resource changes state. Works similarly to notifies, but the direction of the relationship is reversed.
↓
アクションをこのリソースには、別のリソース状態を変更します。作品は、同様に通知します、しかし、関係の方向が逆になっています。
何いってんだ(AA略
恐らくnotifiesの逆。
ブッ殺すって思った時に行動が終わってなきゃいけない模様。プロシュート兄貴属性ですね。
恐らくこんな感じ。
execute "ブッ殺す" do command "ザ・グレイトフル・デッド" end execute "ブッ殺すと思う" do Chef::Log::info("ブッ殺したッ!") subscribes :run resources("execute[ブッ殺す]"), :immediately end
さてリソースが実行されるタイミングの注意点も記載されてます。
By default, notifications are :delayed, that is they are queued up as they are triggered, and then executed at the very end of the Chef run. If you want to run an action immediately, use :immediately:
標準だとchefの最後に実行されるdelayなので、即時実行したいときは:immediatelyを指定するといいよ。
とのこと。