Search code examples
linuxmongodbchef-infrachef-recipecookbook

Does chef-client run on startup?


Does chef-client run as part of a server's startup or just on the next internal set by the chef-client cookbook?

Is there a chef-client cookbook setting to make servers do a chef-client run as soon as they bootup (didn't see one) without having to manually edit startup scripts?

I am asking because I am disabling transparent pages (as per this mongo doc).

I can easily have a recipe echo the right parameter to the correct files, but on reboot the setting switches back. If I know chef-client will run on reboot first thing I won't have to worry about messing with startup scripts.


Solution

  • By default, chef-client is not configured to be run as init task. Though, The chef-client can be run as a daemon. chef-client cookbook can be used to configure the chef-client as a daemon. Add the default recipe to a node’s run-list, and then use attributes in that cookbook to configure the behavior of the chef-client.

    https://docs.chef.io/ctl_chef_client.html#run-as-a-service

    If you want you can configure it as init service with chef-client::init_service recipe.

    https://github.com/chef-cookbooks/chef-client/blob/master/recipes/init_service.rb