Staging Drupal: Change Management Strategies for Drupal
-
Upload
erich-beyrent -
Category
Technology
-
view
122 -
download
0
description
Transcript of Staging Drupal: Change Management Strategies for Drupal
Staging Drupal – Change Management Strategies DrupalCamp NH 2011
Staging DrupalChange Management Strategies for
Drupal
http://twitter.com/ebeyrent
http://drupal.org/user/23897
DrupalCamp NH 2011
Introductions
Permissions API
Permissions Superuser
Crowd SSO
LDAP Extended Groups
Context Local Tasks
Search Lucene Biblio
Search Lucene Attachments
Search Lucene OG
Visual Search API
My Modules
Staging Drupal – Change Management Strategies
Erich Beyrent
Agenda Playing well with others Managing code changes Managing database changes Managing content changes Deployment strategies
DrupalCamp NH 2011Staging Drupal – Change Management Strategies
Staging? What is that?
“Staging” is the process of delivering changes from one environment to another.
DrupalCamp NH 2011Staging Drupal – Change Management Strategies
I develop on the live server. I work alone. Backups?
DrupalCamp NH 2011Staging Drupal – Change Management Strategies
The Manual Process
Point. Click. Wait. Rinse and repeat.
DrupalCamp NH 2011Staging Drupal – Change Management Strategies
Why it fails
It's tedious. It's time-consuming. It's error-prone. It's risky.
DrupalCamp NH 2011Staging Drupal – Change Management Strategies
The staging process should be:
• Reliable
• Repeatable
• Scalable
• Efficient
DrupalCamp NH 2011Staging Drupal – Change Management Strategies
Staging Goals
Anatomy of a Drupal Site
DrupalCamp NH 2011Staging Drupal – Change Management Strategies
Code
FilesConfiguration
Content
A traditional approach
Use source control
Staging Drupal – Change Management Strategies DrupalCamp NH 2011
Use source control Essential to the development and
staging process Manages changes to the code over
time With SVN, use a standard repository
layout consisting of “tags, branches, trunk”
Use multiple repositories to separate core code from project code
Staging Drupal – Change Management Strategies DrupalCamp NH 2011
What goes into source control
Code, configuration, theme-based files
Staging Drupal – Change Management Strategies DrupalCamp NH 2011
What goes into source control
Code, configuration, theme-based files Use source control templates for files like settings.php
Staging Drupal – Change Management Strategies DrupalCamp NH 2011
What goes into source control
Code, configuration, theme-based files Use source control templates for files like settings.php
What about database snapshots?
Staging Drupal – Change Management Strategies DrupalCamp NH 2011
What goes into source control
Code, configuration, theme-based files
Use source control templates for files like settings.php What about database snapshots?
Databases are great at storing and retrieving data, not merging and versioning
Staging Drupal – Change Management Strategies DrupalCamp NH 2011
What goes into source control
Code, configuration, theme-based files
Use source control templates for files like settings.php What about database snapshots?
Databases are great at storing and retrieving data, not merging and versioning
What about files?
Staging Drupal – Change Management Strategies DrupalCamp NH 2011
A traditional approach
Use source control Manage changes in code
DrupalCamp NH 2011Staging Drupal – Change Management Strategies
Manage database changes Export your views, panels, rules, and content types
to code Use Exportables and Ctools to export other data Manage configurations with Strongarm Use Permissions API for roles and permissions Use Features
DrupalCamp NH 2011Staging Drupal – Change Management Strategies
Why should we do this? Multiple environments need to be updated Allows for a phased approach to change
management Saves time and money Is fully testable and reproducible Minimizes downtime and helps manage
expectations
Staging Drupal – Change Management Strategies DrupalCamp NH 2011
Enable modulesfunction demo_update_7001() {
$ret = array();
$modules = array(
'ctools',
'context',
'devel',
);
module_enable($modules, TRUE);
return $ret;
}
Staging Drupal – Change Management Strategies DrupalCamp NH 2011
Grant permissionsfunction demo_update_7001() {
$ret = array();
$role = user_role_load_by_name('admin');
$permissions = user_permission_get_modules();
user_role_grant_permissions($role->rid, array_keys($permissions));
return $ret;
}
Staging Drupal – Change Management Strategies DrupalCamp NH 2011
Create content typesfunction demo_update_7001() {
$types = array(
array(
'type' => 'article',
'name' => st('Article'),
'base' => 'node_content',
'description' => st('Description.'),
'custom' => 1,
'modified' => 1,
'locked' => 0,
)
);
Staging Drupal – Change Management Strategies DrupalCamp NH 2011
foreach ($types as $type) {
$type = node_type_set_defaults($type);
node_type_save($type);
node_add_body_field($type);
}
node_types_rebuild();
}
Create taxonomyfunction demo_update_7001() {
$ret = array();
$vocabulary = new stdClass();
$vocabulary->name = st('Categories');
$vocabulary->machine_name = 'categories';
$vocabulary->description = st('Standard node categories');
$vocabulary->hierarchy = 1;
$vocabulary->module = 'demo';
$vocabulary->weight = 0;
taxonomy_vocabulary_save($vocabulary);
return $ret;
}
Staging Drupal – Change Management Strategies DrupalCamp NH 2011
Create taxonomy termsfunction demo_update_7001() {
$ret = array();
$term = new stdClass();
$term->name = st('Drupal');
$term->description = st('Category for all things Drupal');
$term->parent = array(0);
$term->vid = $vocabulary->vid;
taxonomy_term_save($term);
return $ret;
}
Staging Drupal – Change Management Strategies DrupalCamp NH 2011
A traditional approach
Use source control Manage database changes in code Use deployment tools
DrupalCamp NH 2011Staging Drupal – Change Management Strategies
Use deployment tools Source control as a deployment tool
SVN update, post-commit hooks GIT push
drush, rsync, make Hudson, Phing
http://drupal.org/project/phingdrushtask Capistrano
https://github.com/gaspaio/Drupal-Capistrano-Deploy
Drupal Modules• Deploy• Context• Features• Ctools• UUID• Services• Boxes
Compare various staging modules:http://drupal.org/node/980186
Staging Drupal – Change Management Strategies DrupalCamp NH 2011
The process Import current database snapshot into your sandbox
Scrub your database!
Update your codebase Develop, commit, update Promote changes to QA environment, test Tag or branch and release Drink beer
DrupalCamp NH 2011Staging Drupal – Change Management Strategies
Test the process Install the Demo module Take snapshot Run update.php Verify results, watchdog, error_log Rewind
DrupalCamp NH 2011Staging Drupal – Change Management Strategies
What about content??
Staging Drupal – Change Management Strategies DrupalCamp NH 2011
• Staging content in Drupal sucks• Several options, but none are 100% reliable
• All depend on the UUID module• Deploy, Node Export, Migrate, Services• Error-prone, authentication issues, transport
errors
Drupal 8• Proper configuration management
• A robust entity API and UUIDs in core
• Join the discussion at http://groups.drupal.org/build-systems-change-management/cmi