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,
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 ?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With