The Basics of Smart Drupal Deployment

4,893 views
4,692 views

Published on

Published in: Technology, Sports
3 Comments
4 Likes
Statistics
Notes
No Downloads
Views
Total views
4,893
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
57
Comments
3
Likes
4
Embeds 0
No embeds

No notes for slide

The Basics of Smart Drupal Deployment

  1. 1. The Basics of Smart Erik Webb @erikwebb Drupal Deployment
  2. 2. 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
  3. 3. Defining Deployment
  4. 4. 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
  5. 5. 3.5 Environments• Production • Local • Hands-off • Match software versions• Staging • IDE-focused • Sign-off• Development • Integration
  6. 6. The 3 Cs (and an F)• Code only moves up• Configuration lives only in code• Content only moves down• Files only move down
  7. 7. Version ControlStaying out of your own way
  8. 8. Using Branches and Tags• Branches • Tags • Dynamic • Static • Ongoing work • Releases • Strategic • Periodic
  9. 9. Version Control Workflow
  10. 10. Keeping Version Control Sane• Ignore inappropriate files • Uploaded files directory • settings.php• Prevent bad PHP using lint checks• Don’t be afraid to blame!
  11. 11. Moving Configuration to CodeTools and techniques
  12. 12. Usual Suspects• CTools export • Strongarm • Bulk Exporter • Boxes • Views • UUID • Panels • Node export• Features• Features extra
  13. 13. Filling the Void• 80% handled by CTools-like exportables• Non-developers stuck• Most give up on final 20%• Breaks entire flow• Exceptions suck!
  14. 14. Update Functions• Built-in Drupal feature• Well understood and supported• Only functional code• http://api.drupal.org/hook_update_N
  15. 15. 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.); }
  16. 16. 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.); }
  17. 17. Next StepsDeploying like a Pro
  18. 18. Deploying via Version Control• Atomic (ACID) • svn update• Tools • Post-commit hooks • Jenkins • Capistrano
  19. 19. Drush Deployment• Checkout code from version control • Protect files using ownership• Point web server to new version• drush up• drush cc all
  20. 20. Jenkins• “Fancy cron”• Triggered by polling SCM• Integrate deployment with other tools • Selenium • jMeter• Run commands only on success (atomicity)
  21. 21. Q&ASlides will be posted on www.erikwebb.net and SlideShareSee more at DrupalCamp SC on June 12, 2011
  22. 22. 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/

×