概要
Subscribeで他のリソースをトリガーに任意のアクションを実行する
詳細
Subscribeで他のリソースをトリガーに任意のアクションを実行します。
resource "some_resource" do # options subscribes :action, "target_resource" end
詳細については公式サイトリンクを参照。
http://docs.opscode.com/resource_common.html#subscribes-syntax
サンプル
コード
takuhaiをインストールした際にexecute[notification_sample]を呼び出され、
execute[notification_sample]が呼び出された際に
execute[subscript_sample]が呼び出される。
execute "notification_sample" do command "echo notification!!!!! > /home/vagrant/notification.txt" end execute "subscript_sample" do command "echo subscribe!!!!! > /home/vagrant/subscribe.txt" notifies :run, "execute[notification_sample]" end gem_package "takuhai" do action :install version "0.0.1" notifies :run, "execute[notification_sample]" end
実行結果確認
$ pwd /home/vagrant $ cat subscribe.txt subscribe!!!!!