I’m trying to get chef-client to run automatically at semi-regular intervals.
I’m using the chef-client cookbook
(http://community.opscode.com/cookbooks/chef-client) and its default recipe
(i.e. not cron).
If I’m reading and understanding the README correctly, simply adding the
cookbook to my node’s runlist should set it up as a service and make it run
every + where the default values are 1800 and 300.
I’m modifying the default interval value to 180, so again, if I’m understanding
this right, chef-client should run automatically every 3 minutes at a minimum,
and every 8 minutes at the most.
I’m setting the interval attribute via an environment and I can see in the web
UI that my custom value “took”.
Finally, I can see that the service is installed properly in /etc/init.d/.
If it matters, I’m working with a Vagrant VM running Ubuntu 12.04 LTS
Assuming I’m starting with the VM powered off, I’ll start it, it appears that
chef-client starts automatically, checks in to the server successfully every
few minutes for a bit, and then the process vanishes and it never runs again
unless I restart the service manually, and then the above pattern repeats
If I look at /var/log/chef/client.log, I see these entries:
[2014-04-07T10:03:45-04:00] FATAL: Chef is already running pid 990
[2014-04-07T10:21:09-04:00] FATAL: Chef is already running pid 2108
[2014-04-07T11:02:11-04:00] FATAL: Chef is already running pid 3099
[2014-04-07T11:24:30-04:00] FATAL: Chef is already running pid 969
(I checked the pid for this last run and it was indeed 969).
So just now I restarted it:
root@fabiendelpierre-starter:/var/log/chef# /etc/init.d/chef-client start
- Starting chef-client chef-client
[ OK ]
root@fabiendelpierre-starter:/var/log/chef# ps -A |grep chef
2406 ? 00:00:00 chef-client
I waited a bit, saw in the web UI that it checked in successfully (and I
updated an attribute and saw the new value so I know it ran successfully)…
and now I see the process is gone and there’s this new entry in my
[2014-04-07T11:32:24-04:00] FATAL: Chef is already running pid 2406
If it matters, the attribute I modified was splay, I just change it by a few
seconds just to make sure the runs work. Currently it’s set to 270, I had it
set as low as 250 earlier and I make it vary between 250 and 300.
So why won’t chef-client keep running and/or why does it stop and just die when
it finds that there’s already an instance of itself?
Just for some background info, I’m quite new to Chef and the world of DevOps as
I recently accepted an internal promotion to a DevOps role (from a sysadmin
role) and I’m trying to build my knowledge in small steps – one of them is to
set up Chef nodes that check in to Hosted Chef automatically, all the time so I
can start looking at a properly automated continuous integration system. If
this isn’t the right way to do it, I’m open to suggestions