Day 77: Configuring the chef-client to run using cron

In last week’s post, Day 72: Deploying the SCCM 2012 R2 Client to Linux using Chef, we demonstrated a recipe for deploying the SCCM 2012 R2 Client to a Linux Host running Ubuntu Server 12.04. In this week’s post, we’ll be going over how to configure your Chef Client’s running on Linux to report back into the Chef Server on a regular basis using cron.

 

There are a variety of different ways you can have your Chef Clients running on Linux to report back into a Chef Server at regular intervals; however the method we are going to focus on here is cron. The example provided below is using Chef Client 11.16.4.

 

 

Setting up a Cron Job for chef-client

Cron is a time-based scheduler for Unix based environments used to run commands or scripts at regularly timed intervals. Its equivalent in Windows is Task Scheduler.

The following cron job sample will work in Ubuntu Server 12.04. Paste in the entry below into a file called chef-client under the directory /etc/cron.d/

 

The entry above will do the following:

– Runs chef-client every 5 minutes as root
– log level is set to error (the other options available are debug, info, warn, error, or fatal)
– any errors based upon the log level set are output to the chef-client log file in /var/log

 

After saving and closing your new cron job, you should look into the Web UI Console of your Chef Server to verify that it is reporting in as configured. If it is not, see if there are any entries in /var/log/chef-client.

 

Note that the current Opscode chef-client Cookbook has existing recipes for performing this exact functionality (and then some).

 

 

 

Conclusion

This week’s post has demonstrated how to configure your Chef Client’s running on Linux to report back into the Chef Server on a regular basis using cron.

 

 

Previous Installments

100 Days of DevOps with PowerShell

 

 

 

 

 

Leave a Reply