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