Bastian Widmer / @dasrecht
Manage and Deploy your
sites with Drush
Who are you?
Bastian Widmer
@dasrecht / bastianwidmer.ch
Switzerland
DevOps @ Amazee Labs
Agenda 1 Introduction
2
3
4
5
Where we want to go!
Where we are today?
Putting it together
Outlook to D8
Where we are today
• 3rd party deployment frameworks 

(e.g. capistrano, idephix)
• Deployment „Strategies“
• rsync
• scp
...
Cluster SSH, anyone?
„the DevOps way to kill 5 servers with one keystroke“
Where we want to go!
• Deploying with a tool we know at heart : DRUSH
• Multi Server Deployments
• Running Tasks
• Git Rem...
Where we want to go!
• Deploying with a tool we know at heart : DRUSH
• Multi Server Deployments
• Running Tasks
• Git Rem...
Look at your future
deployment
Now, back to me…
Putting the parts together, shall we?
Parts 1 Installing Drush Deploy
2
3
4
Drush Deploy Configuration
Drush Aliases
The first deployment
Installing drush-deploy
• cd ~/.drush
• git clone --branch 7.x-1.x http://git.drupal.org/
project/drush_deploy.git
Now getting your
Drupal site ready
Standardisation!
• Cleanup your environments
• Establish standards for
• Configurations (e.g. settings.php)
• File paths (...
aliases.drushrc.php
1 <?php!
2 $aliases['web1'] = array(!
3 'root' => '/var/www/drupal',!
4 'remote-user' => 'www-data',!
...
1 <?php!
2 $aliases['web1'] = array(!
3 'root' => '/var/www/drupal',!
4 'remote-user' => 'www-data',!
5 'remote-host' => '...
Drush Deploy
Configuration
deploy.drushrc.php
1 <?php!
2 $options['application'] = 'drupal';!
3 $options['deploy-repository'] = 'git@github.com:Amaze...
deploy.drushrc.php
1 <?php!
2 $options['application'] = 'drupal';!
3 $options['deploy-repository'] = 'git@github.com:Amaze...
deploy.drushrc.php
1 <?php!
2 $options['application'] = 'drupal';!
3 $options['deploy-repository'] = 'git@github.com:Amaze...
deploy.drushrc.php
1 <?php!
2 $options['application'] = 'drupal';!
3 $options['deploy-repository'] = 'git@github.com:Amaze...
deploy.drushrc.php
1 <?php!
2 $options['application'] = 'drupal';!
3 $options['deploy-repository'] = 'git@github.com:Amaze...
deploy.drushrc.php
1 <?php!
2 $options['application'] = 'drupal';!
3 $options['deploy-repository'] = 'git@github.com:Amaze...
Filesystem Structure
Prepare your server :
drush deploy-setup
@web1
Filesystem Structure
Current Release
Is a symlink to the
latest release
directory
Filesystem Structure
Releases
Filesystem Structure
Shared (Git Cache /
Configuration)
Filesystem Structure
Webroot (symlink to current)
• updates your remote cache
• initializes and updates git submodules
• creates a new release directory
• copies your curre...
drush deploy-rollback @web1
• relinks the current directory with the last release
• removes the faulty release
Nice but what about
drush deploy @live
aliases.drushrc.php
• Multi Server Deployments? Alias Lists!
10 $aliases['live'] = array(!
11 'site-list' => array('@web1'...
Automated aliases!
• aliases are built on the fly
• information about servers is stored in a json file
• server groups are...
Automated aliases!
1 <?php!
2 !
3 $sitename = 'CHANGEME';!
4 !
5 // - DO NOT make changes below this Comment!
6 !
7 // Bas...
Time to Implement?
Deployment Tasks
• Before or after moving to new version
• on one or all servers
1 $options['before']['deploy-symlink'][] ...
Deployment Tasks
• update and link settings.php
• link /sites/default/files
• drush updb
• drush cc all
• notify NewRelic ...
Missing Things
• „I just want to update code“ - without running
Tasks
• adding ssh known hosts - connecting to github
on a...
Outlook Drupal 8
• Configuration Management Initiative

www.drupal8cmi.org
• Dealing with Configuration Files
• HEAD is cu...
Take Home
• You don’t have to do all at once
• Automatic aliases files are awesome
• Cleanup your environments
• Standardi...
Thank you for having me
here!
Slides : http://s.nrdy.ch/drush-deploy
Upcoming SlideShare
Loading in …5
×

Manage and Deploy your sites with Drush

3,204
-1

Published on

Drush is not only awesome for managing your local Drupal site, with site aliases you can manage Drupal sites on remote servers without logging in via SSH!

With Drush Deploy you even can deploy sites on multiple servers fully automated with one tool we all aready know: Drush, no other additional library like Capistrano needed!

In this Session we will present how to setup Drush to work with remote sites, what is possible and what we use in our daily business.

Then we will dig deeper into Drush Deploy: how it works, what it does and show how to set it up to deploy a drupal site on multiple servers with a single command, with automated backups, database updates, cache clears and even rollback functionalities.

Published in: Internet
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,204
On Slideshare
0
From Embeds
0
Number of Embeds
42
Actions
Shares
0
Downloads
11
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Manage and Deploy your sites with Drush

  1. 1. Bastian Widmer / @dasrecht Manage and Deploy your sites with Drush
  2. 2. Who are you? Bastian Widmer @dasrecht / bastianwidmer.ch Switzerland DevOps @ Amazee Labs
  3. 3. Agenda 1 Introduction 2 3 4 5 Where we want to go! Where we are today? Putting it together Outlook to D8
  4. 4. Where we are today • 3rd party deployment frameworks 
 (e.g. capistrano, idephix) • Deployment „Strategies“ • rsync • scp • ftp upload • git pull (and pray)
  5. 5. Cluster SSH, anyone? „the DevOps way to kill 5 servers with one keystroke“
  6. 6. Where we want to go! • Deploying with a tool we know at heart : DRUSH • Multi Server Deployments • Running Tasks • Git Remote cache • Possibility to rollback a release
  7. 7. Where we want to go! • Deploying with a tool we know at heart : DRUSH • Multi Server Deployments • Running Tasks • Git Remote cache • Possibility to rollback a release More Automation leaves less room to human error
  8. 8. Look at your future deployment
  9. 9. Now, back to me… Putting the parts together, shall we?
  10. 10. Parts 1 Installing Drush Deploy 2 3 4 Drush Deploy Configuration Drush Aliases The first deployment
  11. 11. Installing drush-deploy • cd ~/.drush • git clone --branch 7.x-1.x http://git.drupal.org/ project/drush_deploy.git
  12. 12. Now getting your Drupal site ready
  13. 13. Standardisation! • Cleanup your environments • Establish standards for • Configurations (e.g. settings.php) • File paths (/sites/defaults/files) • Webroot paths
  14. 14. aliases.drushrc.php 1 <?php! 2 $aliases['web1'] = array(! 3 'root' => '/var/www/drupal',! 4 'remote-user' => 'www-data',! 5 'remote-host' => 'web1.example.com',! 6 );! 7 $aliases['web2'] = $aliases['web1'];! 8 $aliases['web2']['remote-host'] = 'web2.example.com';! 9 ?>!
  15. 15. 1 <?php! 2 $aliases['web1'] = array(! 3 'root' => '/var/www/drupal',! 4 'remote-user' => 'www-data',! 5 'remote-host' => 'web1.example.com',! 6 );! 7 $aliases['web2'] = $aliases['web1'];! 8 $aliases['web2']['remote-host'] = 'web2.example.com';! 9 ?>! drush @web1 user-login drush sql-sync @web1 default aliases.drushrc.php
  16. 16. Drush Deploy Configuration
  17. 17. deploy.drushrc.php 1 <?php! 2 $options['application'] = 'drupal';! 3 $options['deploy-repository'] = 'git@github.com:AmazeeLabs/ new-site.git';! 4 $options['branch'] = "live";! 5 $options['keep-releases'] = 3;! 6 $options['deploy-via'] = 'RemoteCache';! 7 $options['docroot'] = '/var/www/drupal';! 8 $options['git_enable_submodules'] = TRUE;! 9 ?>!
  18. 18. deploy.drushrc.php 1 <?php! 2 $options['application'] = 'drupal';! 3 $options['deploy-repository'] = 'git@github.com:AmazeeLabs/ new-site.git';! 4 $options['branch'] = "live";! 5 $options['keep-releases'] = 3;! 6 $options['deploy-via'] = 'RemoteCache';! 7 $options['docroot'] = '/var/www/drupal';! 8 $options['git_enable_submodules'] = TRUE;! 9 ?>!
  19. 19. deploy.drushrc.php 1 <?php! 2 $options['application'] = 'drupal';! 3 $options['deploy-repository'] = 'git@github.com:AmazeeLabs/ new-site.git';! 4 $options['branch'] = "live";! 5 $options['keep-releases'] = 3;! 6 $options['deploy-via'] = 'RemoteCache';! 7 $options['docroot'] = '/var/www/drupal';! 8 $options['git_enable_submodules'] = TRUE;! 9 ?>! Adopt a GIT Workflow Git Flow : http://s.nrdy.ch/git-flow
  20. 20. deploy.drushrc.php 1 <?php! 2 $options['application'] = 'drupal';! 3 $options['deploy-repository'] = 'git@github.com:AmazeeLabs/ new-site.git';! 4 $options['branch'] = "live";! 5 $options['keep-releases'] = 3;! 6 $options['deploy-via'] = 'RemoteCache';! 7 $options['docroot'] = '/var/www/drupal';! 8 $options['git_enable_submodules'] = TRUE;! 9 ?>!
  21. 21. deploy.drushrc.php 1 <?php! 2 $options['application'] = 'drupal';! 3 $options['deploy-repository'] = 'git@github.com:AmazeeLabs/ new-site.git';! 4 $options['branch'] = "live";! 5 $options['keep-releases'] = 3;! 6 $options['deploy-via'] = 'RemoteCache';! 7 $options['docroot'] = '/var/www/drupal';! 8 $options['git_enable_submodules'] = TRUE;! 9 ?>! keep-releases allows you to roll back to the last state
  22. 22. deploy.drushrc.php 1 <?php! 2 $options['application'] = 'drupal';! 3 $options['deploy-repository'] = 'git@github.com:AmazeeLabs/ new-site.git';! 4 $options['branch'] = "live";! 5 $options['keep-releases'] = 3;! 6 $options['deploy-via'] = 'RemoteCache';! 7 $options['docroot'] = '/var/www/drupal';! 8 $options['git_enable_submodules'] = TRUE;! 9 ?>!
  23. 23. Filesystem Structure Prepare your server : drush deploy-setup @web1
  24. 24. Filesystem Structure Current Release Is a symlink to the latest release directory
  25. 25. Filesystem Structure Releases
  26. 26. Filesystem Structure Shared (Git Cache / Configuration)
  27. 27. Filesystem Structure Webroot (symlink to current)
  28. 28. • updates your remote cache • initializes and updates git submodules • creates a new release directory • copies your current codebase to the release directory • executes your tasks • links the ‚current‘ directory with your new deployed code drush deploy @web1
  29. 29. drush deploy-rollback @web1 • relinks the current directory with the last release • removes the faulty release
  30. 30. Nice but what about drush deploy @live
  31. 31. aliases.drushrc.php • Multi Server Deployments? Alias Lists! 10 $aliases['live'] = array(! 11 'site-list' => array('@web1', '@web2');! 12 ); http://drush.ws/examples/ example.aliases.drushrc.php
  32. 32. Automated aliases! • aliases are built on the fly • information about servers is stored in a json file • server groups are built automatically
  33. 33. Automated aliases! 1 <?php! 2 ! 3 $sitename = 'CHANGEME';! 4 ! 5 // - DO NOT make changes below this Comment! 6 ! 7 // Basic error handling! 8 if($sitename == 'CHANGEME')! 9 die("[ERROR] - Luke, you should change the Sitename in aliases.drushrc.php!n“);! 10 …! http://s.nrdy.ch/drush-aliases
  34. 34. Time to Implement?
  35. 35. Deployment Tasks • Before or after moving to new version • on one or all servers 1 $options['before']['deploy-symlink'][] = 'deploy_settings_php_task';! 2 /**! 3 * The task needs to be defined with a @task "decorator" in the comment block preceding it! 4 * @task! 5 */! 6 function deploy_settings_php_task($d) {! 7 $d->run("cp /home/nfs_share/www-data/`whoami`/settings.php ~/deploy/drupal/ shared/settings.php", $d->latest_release());! 8 }!
  36. 36. Deployment Tasks • update and link settings.php • link /sites/default/files • drush updb • drush cc all • notify NewRelic about the deployment
  37. 37. Missing Things • „I just want to update code“ - without running Tasks • adding ssh known hosts - connecting to github on a new vhost
  38. 38. Outlook Drupal 8 • Configuration Management Initiative
 www.drupal8cmi.org • Dealing with Configuration Files • HEAD is currently moving fast, so changes apply and deployment might not be as easy as with D7
  39. 39. Take Home • You don’t have to do all at once • Automatic aliases files are awesome • Cleanup your environments • Standardisation saves time • Deployments are fun (with drush deploy)
  40. 40. Thank you for having me here! Slides : http://s.nrdy.ch/drush-deploy
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×