D7: Make a Custom Site Deploy Module with One Drush Command

Thanks to the writing and efforts of Dcycle, Befused and others, there is a lot of good information out there on why and how to use a custom deploy module in Drupal 7 to manage the deployments of code and settings on your websites.  They describe them pretty clearly and make it a simple process to copy and paste  bits of code to assemble your own custom deploy module.  What could be wasier than that?  How about 'drush site-deploy-init'. That one command will build a site_deploy module for you inside modules/custom.  Of course to get that one command, you have to  'drush en hook_update_deploy_tools' first.

Hook Update Deploy Tools gives you a lot of power to implement your deploy strategy and it plays nicely with an existing custom deploy module or the module site_deploy that it creates when you 'drush site-deploy-init'.  The reason they get along so well is that hook_update_deploy_tools can be made aware of your custom deploy module(s). For example when you use hook_update_deploy tools to export a Rule, it exports it to your custom deploy module... or your custom Rules Feature.  When you ask it to import your Rule, it knows where to look for the import file.  There is power in contrib modules being aware of custom modules.

For the full list of all the methods that Hook Update Deploy Tools makes available, check the module page as the list is continuously growing.  Here is the list as of today.

  • Enable, Disable, Uninstall Modules

  • Revert Features

  • Delete Fields

  • Update node properties and simple field values

  • Update node aliases

  • Set Drupal variables {alter site config}

  • Create / update Menus from menu import file

  • Create / update rules from a rule import file

  • Export rules with Drush

  • Messages and logging

 

section: