com
com

Reputation: 2704

chef automatically update configuration

I use chef-server and chef-client configuration.

There is a one recipe that I want to rerun on every hosts that contains it on every change in hosts configuration (new hosts added by bootstrapping or the old one was deleted), there is no changes in recipe itself.

By now, I simply run chef-client every 5 min in cron, which is not the best solution.

In general, even if I change the recipe, does chef-client know that it should rerun the recipe? (How does it know, and how long it might take to identify changes in the recipe)

If I need to rerun the recipe without changes in the recipe itself, what is the right way to do so?

Thanks!

Upvotes: 2

Views: 6719

Answers (2)

benathon
benathon

Reputation: 7653

Here is a debian startup script which will use chef's -i and -s params and run chef at system start:

https://github.com/opscode/chef/blob/4edd48d5b546542ed566b1b3f491774e9f36065d/distro/debian/etc/init.d/chef-client

Upvotes: 1

ottodidakt
ottodidakt

Reputation: 3751

If I need to rerun the recipe without changes in the recipe itself, what is the right way to do so?

See Mark's response. chef-client -i 3600 -s 600

In general, even if I change the recipe, does chef-client know that it should rerun the recipe?

No. It doesn't know. If you change and knife-upload the recipie to chef-server, it will provide that version (assuming no environment based version override) to a chef-client the next time it asks the chef-server for the set of recipies needed for a converge.

To satisfy both your use cases, it is best to have an external version control system (such as git) as the source-of-truth for your recipies, write a post-commit-hook that will knife upload every new version of a recipie to the chef-server, and may be even have a CI server listen for check-ins and orchestrate chef-client runs. Some good answers here:

https://serverfault.com/questions/283470/what-are-the-benefits-of-running-chef-server-instead-of-chef-solo

Upvotes: 1

Related Questions