dpkg_autostart cookbook

Cookbook Version (opens in a new tab) Build Status (opens in a new tab) OpenCollective OpenCollective License (opens in a new tab)

dpkg likes to start services after installation as the Debian convention dictates. This can be annoying and problematic, especially when you don't want services to be immediately started before custom configuration can be applied. Instead of disabling all services from auto starting on installation as the dpkg_deb_unautostart cookbook does, lets allow specific services to be targeted.



Include the cookbook as a dependency in your metadata:

depends 'dpkg_autostart'

Then, within your recipe, disable the service with the resource:

dpkg_autostart 'mysql-server' do
  allow false

That's it. When dpkg attempts to start the service after install (generally via apt) it will be instructed not to. This allows the proper configuration files to be generated, and the service to be started after everything is ready.


You can also provide a list of services to disable via node attribute. Add the default recipe to the run list:

run_list 'recipe[dpkg_autostart]'

and set the services you want to restrict from auto starting:

node.default['dpkg_autostart']['disabled_services'] = ['mysql-server', 'apache2']



This project exists thanks to all the people who contribute. (opens in a new tab)


Thank you to all our backers!


Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

Was this helpful?