我想声明一个资源,我想多次运行通知,只有通知。 声明后,如何防止资源自行运行?
有没有办法检查是否有通知,所以我可以运行像“only_if:通知”?
使用action :nothing在声明中action :nothing
这是一个例子,我的execute资源只有在我的directory资源收敛时才会聚合:
directory '/opt/foo' do action :create notifies :run, 'execute[custom command]', :immediately end execute 'custom command' do command 'echo foo' action :nothing end
有关更多示例,请参阅https://docs.chef.io/chef/resources.html#notifications 。