厨师:如何仅在通知上运行资源?


11

我想声明一个我想在通知时仅在通知时运行多次的资源。声明资源后如何防止其自行运行?

有没有什么方法可以检查是否存在通知,所以我可以运行“ only_if:notified”之类的东西?

Answers:



14

这是一个示例,其中我的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

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.