Chef: How to run a resource on notification only?
Solution 1:
Use action :nothing
during declaration.
Solution 2:
Here is an example where my execute
resource is only converged when my directory
resource converges:
directory '/opt/foo' do
action :create
notifies :run, 'execute[custom command]', :immediately
end
execute 'custom command' do
command 'echo foo'
action :nothing
end
See https://docs.chef.io/chef/resources.html#notifications for more examples.