The Basics of Smart Drupal Deployment
-
Upload
erik-webb -
Category
Technology
-
view
4.040 -
download
1
Transcript of The Basics of Smart Drupal Deployment
The Basics of Smart Drupal Deployment
Erik Webb@erikwebb
Background
• Technical Consultant at Acquia
• Focus on best practices, infrastructure, and developer training
• Working with Drupal ~3.5 years
• Previously Red Hat sysadmin at Georgia Tech and application developer at IBM
Defining Deployment
What is deployment?
• Maintaining multiple, independent environments
• Effortlessly migrating and testing changes between them
• Safely updating without downtime or rollbacks
• Accounting for changes in a sustainable way
3.5 Environments
• Production
• Hands-off
• Staging
• Sign-off
• Development
• Integration
• Local
• Match software versions
• IDE-focused
The 3 C's (and an F)
• Code only moves up
• Configuration lives only in code
• Content only moves down
• Files only move down
Version Control
Staying out of your own way
Using Branches and Tags
• Branches
• Dynamic
• Ongoing work
• Strategic
• Tags
• Static
• Releases
• Periodic
Version Control Workflow
Keeping Version Control Sane
• Ignore inappropriate files
• Uploaded files directory
• settings.php
• Prevent bad PHP using lint checks
• Don’t be afraid to blame!
Moving Configuration to Code
Tools and techniques
Usual Suspects
• CTools export
• Bulk Exporter
• Views
• Panels
• Features
• Features extra
• Strongarm
• Boxes
• UUID
• Node export
Filling the Void
• 80% handled by CTools-like exportables
• Non-developers stuck
• Most give up on final 20%
• Breaks entire flow
• Exceptions suck!
Update Functions
• Built-in Drupal feature
• Well understood and supported
• Only functional code
• http://api.drupal.org/hook_update_N
Update Functions using Helpers
/*** @see forum_enable().*/function mymodule_update_7000() { $vocab = array( 'name' => t('Forums'), 'machine_name' => 'forums', 'description' => t('Forum navigation vocabulary'), 'hierarchy' => 1, 'module' => 'forum', 'weight' => -10, ); $vocabulary = (object) $vocab; taxonomy_vocabulary_save($vocabulary);
return t('New vocabulary imported.');}
Update Functions using SQL
/*** @link http://drupal.org/node/310079*/function mymodule_update_7001() { $pid = db_insert('mytable') ->fields(array( 'col1' => 'value', 'col2' => 'value', )) ->execute();
return t('New row imported.');}
Next Steps
Deploying like a Pro
Deploying via Version Control
• Atomic (ACID)
• svn update
• Tools
• Post-commit hooks
• Jenkins
• Capistrano
Drush Deployment
• Checkout code from version control
• Protect files using ownership
• Point web server to new version
• drush up
• drush cc all
Jenkins
• “Fancy cron”
• Triggered by polling SCM
• Integrate deployment with other tools
• Selenium
• jMeter
• Run commands only on success (atomicity)
Q&A
Slides will be posted on www.erikwebb.net and SlideShare
See more at DrupalCamp SC on June 12, 2011
Photo credits
• “Advanced Theoretical Physics”, Marvin (PA) on Flickr. http://www.flickr.com/photos/55853619@N00/145052885/
• “Sugar rush from the cupcake wore off”, slworkin2 on Flickr. http://www.flickr.com/photos/18548283@N00/3094340010/
• “Collision between two engines, Bay of Quinte Railway, ON, 1892”, Musée McCord Museum on Flickr. http://www.flickr.com/photos/25786829@N08/2918567169/
• “Square Peg in a Round Hole”, casa.pokayoke on Flickr. http://www.flickr.com/photos/43740025@N03/4184481846/
• “Vacation in my backyard”, mandolin davis on Flickr. http://www.flickr.com/photos/43546149@N00/258014588/