The Basics of Smart Drupal Deployment

26
The Basics of Smart Drupal Deployment Erik Webb @erikwebb

Transcript of The Basics of Smart Drupal Deployment

Page 1: The Basics of Smart Drupal Deployment

The Basics of Smart Drupal Deployment

Erik Webb@erikwebb

Page 2: The Basics of Smart Drupal Deployment

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

Defining Deployment

Page 4: The Basics of Smart Drupal Deployment
Page 5: The Basics of Smart Drupal 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

Page 6: The Basics of Smart Drupal Deployment

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

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

Version Control

Staying out of your own way

Page 9: The Basics of Smart Drupal Deployment
Page 10: The Basics of Smart Drupal Deployment

Using Branches and Tags

• Branches

• Dynamic

• Ongoing work

• Strategic

• Tags

• Static

• Releases

• Periodic

Page 11: The Basics of Smart Drupal Deployment

Version Control Workflow

Page 12: The Basics of Smart Drupal Deployment

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

Moving Configuration to Code

Tools and techniques

Page 14: The Basics of Smart Drupal Deployment
Page 15: The Basics of Smart Drupal Deployment

Usual Suspects

• CTools export

• Bulk Exporter

• Views

• Panels

• Features

• Features extra

• Strongarm

• Boxes

• UUID

• Node export

Page 16: The Basics of Smart Drupal Deployment

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

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

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

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

Next Steps

Deploying like a Pro

Page 21: The Basics of Smart Drupal Deployment
Page 22: The Basics of Smart Drupal Deployment

Deploying via Version Control

• Atomic (ACID)

• svn update

• Tools

• Post-commit hooks

• Jenkins

• Capistrano

Page 23: The Basics of Smart Drupal Deployment

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

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

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

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/