Below is my recipe for installing monit. I am running chef client every 60 seconds to debug.
Chef if restarting monit evry 60 seconds. No do I stop that? I thought chef will restart if change a templete.
[Fri, 30 Mar 2012 06:12:18 +0000] INFO: Processing package[monit] action install (monit::default line 5)
[Fri, 30 Mar 2012 06:12:18 +0000] INFO: Processing service[monit] action enable (monit::default line 9)
[Fri, 30 Mar 2012 06:12:18 +0000] INFO: Processing service[monit] action start (monit::default line 9)
[Fri, 30 Mar 2012 06:12:18 +0000] INFO: Processing template[monitrc] action create (monit::default line 14)
[Fri, 30 Mar 2012 06:12:18 +0000] INFO: template[monitrc] mode changed to 644
[Fri, 30 Mar 2012 06:12:18 +0000] INFO: template[monitrc] sending restart action to service[monit] (immediate)
[Fri, 30 Mar 2012 06:12:18 +0000] INFO: Processing service[monit] action restart (monit::default line 9)
[Fri, 30 Mar 2012 06:12:22 +0000] INFO: service[monit] restarted
[Fri, 30 Mar 2012 06:12:22 +0000] INFO: Processing template[monitstart] action create (monit::default line 25)
package "monit" do
action :install
end
service "monit" do
supports :status => true, :restart => true, :start => true,:stop => true
action [ :enable, :start ]
end
template "monitrc" do
path "/etc/monit/monitrc"
source "monitrc.erb"
owner "root"
group "root"
mode "0644"
#notifies :restart, resources(:service => "monit")
#notifies :restart, "service[monit]"
notifies :restart, resources(:service => "monit"), :immediate
end
template "monitstart" do
path "/etc/default/monit"
source "monit.erb"
owner "root"
group "root"
mode "0644"
notifies :restart, "service[monit]"
#notifies :restart, resources(:service => "monit"), :immediate
end
Every time monit service restarts it changes the file
/etc/monit/monitrcpermission to 600 so only root can read e write it, probably some sort of security reinforcement.But when your recipe runs it changes the permission to 644, restarting the service which puts the file back with 600. It’s like a dog chasing his own tail.
A simple solution would be to change your recipe to apply 600 on the template avoiding the restart.