Sync enabled modules between sites

Events happening in the community are now at Drupal community events on www.drupal.org.
leon kessler's picture

So in the process of updating my development site, a new module has been installed. One of my previously installed modules has since become dependent on this new module.

So to get this on to my live/staging site, I use version control to update so that it has the same code as my dev site.
Now I have an issue, I need to enable that new module.

I could simply enable the module manually in drush, but there could be several modules, and I may accidentally miss one.
Plus, I want to write a script that does all of this in one command (with all the other stuff I need to do, sql-sync, run tests, etc).

So ideally, I want a way to sync enabled modules between two sites. But only for specific modules (e.g. devel module should only be installed on dev, I found the environment module that can help with that)

Can anyone recommend a method for doing this? Or propose an alternative workflow?

Comments

My too-brief answer: use a

greg.1.anderson's picture

My too-brief answer: use a post-sync hook. No time to say more at the moment...

Wait, that is a nonsensical answer.

greg.1.anderson's picture

I was thinking you are using drush rsync, but you are using your vcs. The concept is the same, except you do not use a hook, it is just a command. You can use pm-list to find the enabled modules on each system, diff them, take some modules out via config if they are development only (devel, hacked, etc.). Look in includes/commands for functions to call drush functions with -- drush_invoke_sitealias_args(), etc., and see drush_backend_get_result() for comments on how to interpret the results.

And of course, the even better answer...

greg.1.anderson's picture

Use features.

Thanks greg

leon kessler's picture

That's great help.

I figured it would need some work to achieve, but thanks for the pointers.

On another note, how would I use features for this? I'm already using features for exporting anything that features supports. But there's a whole bunch of stuff that it doesn't.
Plus how would features be able to enable a module?

Incidentally, I did the

owen barton's picture

Incidentally, I did the diffing of pm-list as an example in out Drupalcon Chicago session - you might want to check out the video. An alternative to diffing that may be a bit simpler from a command line point of view would simply be to pm-list disabled modules on site A, disable those on site A (this can be a single command, using --pipe and | into the disable command), and then pm-list enabled modules on site A, then enable those on site B (another single command using pipe). You could also make your own drush command that calls the pm-list and enable/disable commands (or just functions) and does the same thing with arrays.

Use drux

donquixote's picture

A nice solution is https://github.com/donquixote/drupal-drux.

The idea is to use "seed" modules that contain nothing but dependencies to other modules.
These can be created with Features, or manually.
(If you do it manually, I would recommend to always sort the dependencies alphabetically. If you use Features, that will happen automatically)

With a typical dev + production work flow, you would create two seed modules: mysite_dependencies and mysite_dev_dependencies. (or however you want to name it).

drux provides a number of commands that help you create and update these modules, and to enable new dependencies.

On dev:

drush drux-find-obsolete mysite_dev_dependencies mysite_dependencies
drush drux-generate mysite_dev_dependencies mysite_dependencies

Copy+paste the new dependencies into the mysite_dependencies.info file, and ideally sort alphabetically. Then git push.

On production, git pull and:

drush drux-list-dependencies
drush drux-enable-dependencies

To enable the missing dependencies.

drush

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: