Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chef daemon running every 30 minutes

Tags:

chef-infra

I understand that Chef is pull based in the sense that it detects any changes in the recipes and uses chef client to install the changes. We use chef to bring up EC2 instances but the chef-client which runs as a daemon every 30 minutes and runs all the recipes again causing unwanted changes to some services. I would like to know what options are there to change this and run the chef-client on a on demand basis.

Following are the options I have thought of so far,

  1. Change the interval time on the chef-client cookbook to very high time so that the daemon does no run often.
  2. After the EC2 instance is deployed kill the chef daemon ssh or maybe even a chef-recipe.

Also I believe chef-client has log rotation scheduled on a weekly basis, this will again restart the chef-client. Any ideas on how to avoid this pull based behavior ?

like image 820
pup784 Avatar asked Feb 15 '13 23:02

pup784


1 Answers

First of all:

Your chef recipes should set your node in 1 and the same configuration, no matter how many times chef is run. You also should never restart any service on your own. This behaviour should be notified by the config files, if they are changed. For example:

service 'apache2' do
  action [:enable, :start]
end

template '/etc/apache2/httpd.conf' do
  action :create
  [...]
  notifies, :restart, 'service[apache2]' #this notification will launch, only if the file has changed
end

You can also disable chef-client daemon, by running chef-client --once. This way chef will provision the node and will remove self from cron. Thus in the future it will be run only manually on demand.

But your bigger problem is actually that your chef-client run causes changes to some of your services with every run. You should solve it first.

like image 194
Draco Ater Avatar answered Oct 13 '22 08:10

Draco Ater