Chef execute block
chef-infra, chef-recipe, ruby
Solution
You should add `action :nothing` to your execute resource.
execute "hashAccess" do
command "makemap hash /etc/mail/access < /etc/mail/access"
action :nothing
notifies :restart, "service[sendmail]"
end
This way it will not be executed, unless notified by other resource.
Problem
I am very new to `Chef`. I have a recipe that installs `sendmail` and it does my configurations. I have noticed that `Chef` restarts the service on every run. That is because I'm running an `execute` that calls the session restart. It looks like this: ``` execute "hashAccess" do command "makemap hash /etc/mail/access < /etc/mail/access" notifies :restart, "service[sendmail]" end ``` I need to call this only when the `access` file if updated. ``` template "/etc/mail/access" do source "access.erb" mode "0644" notifies :run, "execute[hashAccess]" end ``` When the file is updated, the `execute` is called twice. Both of the resources are in the same recipe and when I try to `define` `hashAccess` I get an error ``` ERROR: Cannot find a resource for define on amazon version 2013.09 ``` How do I make the execute resource to run only when called?