Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

DevOps: Cooking Drupal Deployment


Published on

This presentation is aimed on how to automated the Drupal deployment using tools like Git, Drush, Features, and hook_update API.

Published in: Technology
  • Be the first to comment

DevOps: Cooking Drupal Deployment

  1. 1. Drupal Developers Day 2013 Microsoft PH 6750 Ayala Avenue, Makati City
  2. 2. Our Goal?
  3. 3. Zero Touch Deployment
  4. 4. Zero Downtime During Deployment
  5. 5. Deployment Syndrome Fear of Change (before and after delivery)
  6. 6. Deployment Syndrome It works on my machine*
  7. 7. Deployment Syndrome Silo-isolation (different software stack)
  8. 8. DevOps { 'Drupal': cooking => deployment, } Gerald Villorente Senior DevOps Engineer | Open-Source Enthusiast
  9. 9. FTP used to transfer files from one host to another host over a TCP-based network
  10. 10. Prehistoric
  11. 11. Slow
  12. 12. Not Secure
  13. 13. No version control
  14. 14. Manual Configuration
  15. 15. Risky
  16. 16. Repetitive
  17. 17. Solution?
  18. 18. Automate not applicable in shared-hosting
  19. 19. Tools
  20. 20. Git Git /ɡɪt/ is a distributed revision control and source code management (SCM) system with an emphasis on speed. - Wikipedia
  21. 21. Git Hooks: Post  Post-code-deploy (post-merge, post-checkout, etc)  Post-db-copy  Post-files-copy
  22. 22. Git Hooks: Post-code-deploy drush -vdy updb drush -vdy fra drush -vdy cc all
  23. 23. Git Hooks: Post-code-deploy drush drush drush drush -vdy -vdy -vdy -vdy @domain.uat @domain.uat @domain.uat @domain.uat cc all updb fra cc all
  24. 24. Git Hooks: Post-code-deploy drush drush drush drush -vdy -vdy -vdy -vdy @domain.stage @domain.stage @domain.stage @domain.stage cc all updb fra cc all
  25. 25. Git Hooks: Post-code-deploy drush drush drush drush -vdy -vdy -vdy -vdy cc all updb fra cc all
  26. 26. Git Hooks: Post-db-copy drush drush drush drush @domain.uat @domain.uat @domain.uat @domain.uat cc all updb -y fra -y cc all
  27. 27. Git Hooks: Post-db-copy drush @domain.stage cc all drush @domain.stage updb -y drush @domain.stage en views_ui -y drush @domain.stage en context_ui -y drush @domain.stage fra -y drush @domain.stage dis chartbeat -y drush @domain.stage vset cdn_status 0 -y drush @domain.stage solr-vset conf[apachesolr_read_only] 1 -y drush @domain.stage vset preprocess_js 0 -y drush @domain.stage vset preprocess_css 0 -y drush @domain.stage vset purge_proxy_urls '' -y drush @domain.stage cc all
  28. 28. Git Hooks: Post-db-copy drush cc all drush updb -y drush en views_ui -y drush en context_ui -y drush fra -y drush dis chartbeat -y drush vset cdn_status 0 -y drush vset conf[apachesolr_read_only] 1 -y drush vset preprocess_js 0 -y drush vset preprocess_css 0 -y drush vset purge_proxy_urls '' -y drush cc all
  29. 29. Git Hooks: Post-files-copy  Will run after finished copying files - from prod to uat, stage, and or dev - from uat to stage or dev - from stage to uat or dev - from dev to uat or stage
  30. 30. Managing Files  Don't put in version control  Use rsync
  31. 31. Git Hooks: Pre  Pre-commit  Prepare-commit-msg  Pre-applypatch  Pre-rebase
  32. 32. Drush is a command-line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those who spend their working hours hacking away at the command prompt
  33. 33. Drush: Clear Cache Command: $ drush cc all
  34. 34. Drush: Run hook_update Command: $ drush updb -y $ drush updb -y
  35. 35. Drush Make
  36. 36. Drush: Make Capabilities  Downloading Drupal core, as well as contrib modules from  Checking code out from SVN, git, and bzr repositories.    Getting plain `.tar.gz` and `.zip` files (particularly useful for libraries that can not be distributed directly with drupal core or modules). Fetching and applying patches. Fetching modules, themes, and installation profiles, but also external libraries.
  37. 37. Useful Drush Commands not really important in deployment
  38. 38. Drush: SQL Login Command: $ drush sql-cli
  39. 39. Drush: SQL Query Command: $ drush sqlq “UPDATE users SET pass=$S$DHaDeIifGS5qiS7ghhEolZ9lbaRTkZh/UcU.dh ZY0Rpp1gUooEpQ WHERE uid=1”
  40. 40. Drush: SQL Sync Command: $ drush sql-sync @prod @dev
  41. 41. Drush: SQL Create Command: $ drush sql-create $ drush sql-create
  42. 42. Drush: SQL Drop Command: $ drush sql-drop $ drush sql-drop
  43. 43. Drush: SQL Dump Command: $ drush sql-dump --result-file=../bck.sql Options: --gzip --result-file
  44. 44. Drush: Variable Set Command: $ drush vset preprocess_js 1 -y
  45. 45. Drush: Module Enable Command: $ drush en views -y $ drush en features views_ui -y
  46. 46. Drush: Module Disable Command: $ drush dis views -y $ drush dis features views_ui -y
  47. 47. Drush: Module Uninstall Command: $ drush pm-uninstall views -y $ drush pm-uninstall ctools views -y
  48. 48. Drush: One-time Login Command: $ drush uli gerald $ drush uli –browser=firefox
  49. 49. Drush: Update Password Command: $ drush upwd gerald --password=foo
  50. 50. Use Site Alias Allows you to execute Drush commands in target remote server via ssh Command: $ drush updb -y
  51. 51. Features Enables the capture and management of features in Drupal. A feature is a collection of Drupal entities which taken together satisfy a certain use-case.
  52. 52. Features: Create
  53. 53. Features: Manage
  54. 54. Features: Module
  55. 55. Features: Drush Integration features-revert-all (fra) Revert all enabled feature module on your site. Command: drush fra -y Options: --force
  56. 56. Bash A command processor, typically run in a text window, allowing the user to type commands which cause actions. Bash can also read commands from a file, called a script. Like all Unix shells, it supports filename wildcarding, piping, here documents, command substitution, variables and control structures for condition-testing and iteration. - Wikipedia
  57. 57. Bash Scripting: Sample #!/usr/bin/env bash path=”sites/all/default/files” if [ ! -d “$path”]; then mkdir $path chown www-data:www-data $path fi
  58. 58. Bash Scripting: Drush #!/usr/bin/env bash drush cc all drush updb -y drush fra -y drush cc all echo “Delployment done!”
  59. 59. I don't know Bash! You can also use Python, Shell, or Perl. Use the one that you're comfortable with. Just remember, DRY and KISS.
  60. 60. Drupal API
  61. 61. hook_update_N
  62. 62. hook_update_N: Sample /** * Enable Test module. */ function test_update_7001() { $module = array('test'); module_enable($module); }
  63. 63. Demo
  64. 64. What we achieved?
  65. 65. We used Git to managed the entire deployment.
  66. 66. We used Features to capture database changes.
  67. 67. We used Drush to run the hook_update_N, revert the features, and clear the cache.
  68. 68. We created a Bash script that contains deployment process run by Git.
  69. 69. Related DevOps Tools
  70. 70. Puppet Open-souce automation software that helps system administrators manage infrastructure throughout its lifecycle, from provisioning and configuration to orchestration and reporting.
  71. 71. Chef A systems and cloud infrastructure automation framework that makes it easy to deploy servers and applications to any physical, virtual, or cloud location, no matter the size of the infrastructure.
  72. 72. Ansible Ansible configures operating systems, deploys applications, runs parallel commands, and orchestrates IT processes like zero-downtime rolling updates. It uses SSH by default, so no special software has to be installed to start managing remote machines. Modules can be written in any language.
  73. 73. Juju Juju is a powerful service orchestration tool from Ubuntu that helps you define, configure and deploy services to any cloud quickly and easily.
  74. 74. Capistrano Capistrano was originally designed to simplify and automate deployment of web applications to distributed environments.
  75. 75. Docker Docker is an open-source project to easily create lightweight, portable, self-sufficient containers from any application. The same container that a developer builds and tests on a laptop can run at scale, in production, on VMs, bare metal, OpenStack clusters, public clouds and more.
  76. 76. Foreman for managing physical and virtual server
  77. 77. Travis CI distributed continuous integration service used to build and test projects
  78. 78. Jenkins An extendable open source continuous integration server. Built with Java, it provides 829 plugins to support building and testing virtually any project.
  79. 79. Maven Maven allows a project to build using its project object model (POM) and a set of plugins that are shared by all projects using Maven, providing a uniform build system.
  80. 80. rsync Is a file transfer program for Unix systems. rsync uses the "rsync algorithm" which provides a very fast method for bringing remote files into sync. It does this by sending just the differences in the files across the link, without requiring that both sets of files are present at one of the ends of the link beforehand.
  81. 81. Questions?
  82. 82. Resoures        
  83. 83. Contact Details
  84. 84. 10-26-13