The document discusses optimizing Drupal site deployments using Drush and Drush Make. It describes what Drush and Drush Make are and how they can be used to script reliable and flexible site deployments. The document also discusses Features and alternative strategies for programmatically deploying and updating sites using custom modules.
Exploring the Future Potential of AI-Enabled Smartphone Processors
Optimize Site Deployments with Drush (DrupalCamp WNY 2011)
1. Optimize Site Deployments with Drush Friday, 2011.10.14 Jon Peck, Owner, FluxSauce.com Audience: Intermediate. Revision 1. Licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License .
2.
3.
4.
5.
6.
7. What is drush make ? A standard recipe for downloading everything you need for a site installation. "Mom's new pumpkin pie recipe with gingersnaps", CC BY-SA 2.0 by Ann Larie Valentine @ flickr
PHP 4 & 5 Senior developer, development manager and systems administrator Started using Drupal for sites on the side
This presentation is a result of working on multiple sites and trying to reign in both the entropy associated with deployments and out of frustration from having to keep reconfiguring details. The script examples I will be showing use bash, but you can probably do something very similar with Windows if you were so inclined. There are three primary modules that I will highlight today; drush, drush make, and features. The features module is an extremely powerful tool, but it is in no means the final solution. I'll explore both the good and the bad of features. There's many ways to deploy sites; I'll discuss the way I currently do it based on my experience, both working with a in-house, distributed and one-person team. No size fits all, some sizes fit most, and every client is unique. With that said, I hope that these strategies can be incorporated into your deployments and make your life easier.
When you deploy a site, are you crossing your fingers? Do you know exactly what's going to happen? Did you remember every last variable, setting, configuration, module and theme? Leverage software versioning systems to store your configurations. How many people here already use a system like SVN or git? Separate configurations for development, staging and production You can track how long it takes to do things, document why something was done, and constantly improve the process
Drush is a back end tool - a command line shell and scripting interface for Drupal. Easy, fast interface for administrative tasks Originally designed for Drupal 4, it has been maintained and expanded to support Drupal 5, 6 and 7 Many modules include support for Drush This is an example of the status command
Download, enable, disable modules Create, block or cancel users, set passwords, add or remove roles Clear cache, flush images, index search items, update database... Very useful for building custom modules that configure your site Excellent for debugging Notice how it also automatically downloaded the dependency, FirePHP
drush make is an extension that uses a parsed configuration to create a ready-to-use drupal site, downloading from sources as needed Core and contrib from Drupal.org Checking out code from CVS, SVN, git, and bzr repos Get archives for libraries Does not require database It can play nice with installation profiles, but I have not had a need to develop my own using this strategy. It is compatible with Acquia Drupal and Pressflow. Using drush, you can export a drush make configuration from your existing site. drush generate -makefile The website, drushmake.me is a graphical user interface that generates drush make files
Step 1- get the files using drush make. It uses a configuration file; this is same for all environments. Step 2 - Install and configure. You can specify a particular configuration specific to an environment Step 3 - Enable modules using drush
Much like many of you, I have to deal with a large number of sites on a regular basis. With that comes the overhead of keeping track of configurations, variables, tweaks and the such. In response, I developed the Drupal Deployment Skeleton to facilitate the rapid deployment and development of commercial sites. I've open-sourced it to go along with this session so you can leverage it to allow you to create your own scriptable deployments. You must customize these scripts to your environment to be able to use it; this is not a turnkey package. drush.*.php - Site configurations for drush drush.make - drush make configuration config.ini - For each environment, defines where config is and where the site will go install.sh - Performs the actual installation, similar to simplest example setup.sh - Gets path, loads configuration, verifies configuration rebuild.sh - After prompt, destroys database and removes site, then reinstalls
Features is a module that captures and manages a collection of Drupal entities It includes both a graphical user interface and API Bundles exportable components into a single module Very Easy to use
Within your site: Site content Content types Users Roles Module dependencies imagecache presets Menus Permissions Using drush : List all available features Update code of existing feature to include DB changes - drush fu Revert to feature defaults Show a diff
Publishing preference, for example - told it not to publish on the front page, does it anyway You have to keep going over the same changes time and time again. Strongarm exposes some variables, but not all. Themes and blocks have to be manually changed and updated. It's a blunt force instrument, and therefore doesn't handle logic or precedence, like do not do X if Y exists It's a great tool, but if you can't do it in the GUI, your hands are going to get dirty. Fortunately, there is another way.
Beyond the site administrator - the first user, you often will have roles that you want to place your client's users in. For brochure websites in particular, I disable the login block. Depending on the design needs of the client, I will also remove the "Powered by Drupal" block. While you want your client to maintain their own content, often you have static content, pages usually, that you want to populate the site with. Content Construction Kit is a great and easy way to create new content types; you can export them with the UI and import them programatically. Do you use taxonomies to categorize your content? You can easily create vocabularies and terms out of the box. Leverage drush's vget, variable get command to keep track of before and after configuration changes with a quick diff Create WYSIWYG profiles - use them across multiple sites! Imagecache profiles Rather than making you suffer through a bunch of dry examples, they are at the end of the presentation and you can download the slides at your leisure. Store your module in your favorite repository
This is one I learned from hard experience - Some operations require a user to be associated, so enable your custom module separately, explicitly specifying UID 1.
Even if you're a one man shop Backup - especially in production, before making any changes Tiered: Development - working environment for individual developers or small teams. Can also include integration, where the entire team's work is combined and validated. Staging - identical to production as possible, simulating actual release. Also good for demonstration and training. Production - Public facing deployment. Tiering - this can dovetail into a larger discussion of software versioning and branching Make sure everything works the way you want it to You ultimately want someone else to be able to do this for you
The Drush manual is a bit overwhelming, but just search in the page and you'll get the hang of it. Drush make is also well documented; their examples are well worth looking at. What exactly are you trying to accomplish? Are you putting a skeleton in place for your client to fill, or do you have all content already? Cluster it by purpose.Ex: I need imagecache, galleria, cck, file, image, and jquery_update for an image gallery. Get files, install and configure, enable modules