devops: cooking drupal deployment

85
Drupal Developers Day 2013 Drupal Developers Day 2013 Microsoft PH Microsoft PH 6750 Ayala Avenue, Makati City

Upload: gerald-villorente

Post on 08-May-2015

3.215 views

Category:

Technology


3 download

DESCRIPTION

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

TRANSCRIPT

Page 1: DevOps: Cooking Drupal Deployment

Drupal Developers Day 2013Drupal Developers Day 2013

Microsoft PHMicrosoft PH6750 Ayala Avenue, Makati City

Page 2: DevOps: Cooking Drupal Deployment

Our Goal?Our Goal?

Page 3: DevOps: Cooking Drupal Deployment

Zero Touch Zero Touch DeploymentDeployment

Page 4: DevOps: Cooking Drupal Deployment

Zero Downtime Zero Downtime During During

DeploymentDeployment

Page 5: DevOps: Cooking Drupal Deployment

Deployment Deployment SyndromeSyndrome

Fear of Change (before and after delivery)

Page 6: DevOps: Cooking Drupal Deployment

Deployment Deployment SyndromeSyndrome

It works on my machine*

Page 7: DevOps: Cooking Drupal Deployment

Deployment Deployment SyndromeSyndromeSilo-isolation (different software stack)

Page 8: DevOps: Cooking Drupal Deployment

DevOpsDevOps {{ 'Drupal': 'Drupal': cooking => deployment, cooking => deployment,}}

Gerald VillorenteSenior DevOps Engineer | Open-Source Enthusiast

Page 9: DevOps: Cooking Drupal Deployment

FTPFTPused to transfer files from one host to another host over a TCP-based used to transfer files from one host to another host over a TCP-based

networknetwork

Page 10: DevOps: Cooking Drupal Deployment

PrehistoricPrehistoric

Page 11: DevOps: Cooking Drupal Deployment

SlowSlow

Page 12: DevOps: Cooking Drupal Deployment

Not SecureNot Secure

Page 13: DevOps: Cooking Drupal Deployment

No version No version controlcontrol

Page 14: DevOps: Cooking Drupal Deployment

Manual Manual ConfigurationConfiguration

Page 15: DevOps: Cooking Drupal Deployment

RiskyRisky

Page 16: DevOps: Cooking Drupal Deployment

RepetitiveRepetitive

Page 17: DevOps: Cooking Drupal Deployment

Solution?Solution?

Page 18: DevOps: Cooking Drupal Deployment

AutomateAutomatenot applicable in shared-hostingnot applicable in shared-hosting

Page 19: DevOps: Cooking Drupal Deployment

ToolsTools

Page 20: DevOps: Cooking Drupal Deployment

GitGit Git / t/ is a distributed ɡɪGit / t/ is a distributed ɡɪ revision controlrevision control and source code and source code

management (SCM) system with an emphasis on speed. management (SCM) system with an emphasis on speed. - Wikipedia- Wikipedia

Page 21: DevOps: Cooking Drupal Deployment

Git Hooks:Git Hooks: PostPost Post-code-deploy (post-merge, post-checkout, etc) Post-db-copy Post-files-copy

Page 22: DevOps: Cooking Drupal Deployment

Git Hooks:Git Hooks: Post-code-deployPost-code-deploy

drush -vdy @domain.prod updbdrush -vdy @domain.prod fradrush -vdy @domain.prod cc all

Page 23: DevOps: Cooking Drupal Deployment

Git Hooks:Git Hooks: Post-code-deployPost-code-deploy

drush -vdy @domain.uat cc alldrush -vdy @domain.uat updbdrush -vdy @domain.uat fradrush -vdy @domain.uat cc all

Page 24: DevOps: Cooking Drupal Deployment

Git Hooks:Git Hooks: Post-code-deployPost-code-deploy

drush -vdy @domain.stage cc alldrush -vdy @domain.stage updbdrush -vdy @domain.stage fradrush -vdy @domain.stage cc all

Page 25: DevOps: Cooking Drupal Deployment

Git Hooks:Git Hooks: Post-code-deployPost-code-deploy

drush -vdy @domain.dev cc alldrush -vdy @domain.dev updbdrush -vdy @domain.dev fradrush -vdy @domain.dev cc all

Page 26: DevOps: Cooking Drupal Deployment

Git Hooks:Git Hooks: Post-db-copyPost-db-copydrush @domain.uat cc alldrush @domain.uat updb -ydrush @domain.uat fra -ydrush @domain.uat cc all

Page 27: DevOps: Cooking Drupal Deployment

Git Hooks:Git Hooks: Post-db-copyPost-db-copydrush @domain.stage cc alldrush @domain.stage updb -ydrush @domain.stage en views_ui -ydrush @domain.stage en context_ui -ydrush @domain.stage fra -ydrush @domain.stage dis chartbeat -ydrush @domain.stage vset cdn_status 0 -ydrush @domain.stage solr-vset conf[apachesolr_read_only] 1 -ydrush @domain.stage vset preprocess_js 0 -ydrush @domain.stage vset preprocess_css 0 -ydrush @domain.stage vset purge_proxy_urls 'http://stage.domain.com/?purge_method=ah' -ydrush @domain.stage cc all

Page 28: DevOps: Cooking Drupal Deployment

Git Hooks:Git Hooks: Post-db-copyPost-db-copydrush @domain.dev cc alldrush @domain.dev updb -ydrush @domain.dev en views_ui -ydrush @domain.dev en context_ui -ydrush @domain.dev fra -ydrush @domain.dev dis chartbeat -ydrush @domain.dev vset cdn_status 0 -ydrush @domain.dev vset conf[apachesolr_read_only] 1 -ydrush @domain.dev vset preprocess_js 0 -ydrush @domain.dev vset preprocess_css 0 -ydrush @domain.dev vset purge_proxy_urls 'http://stage.domain.com/?purge_method=ah' -ydrush @domain.dev cc all

Page 29: DevOps: Cooking Drupal Deployment

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

Page 30: DevOps: Cooking Drupal Deployment

Managing FilesManaging Files

Don't put in version control Use rsync

Page 31: DevOps: Cooking Drupal Deployment

Git Hooks: PreGit Hooks: Pre Pre-commit Prepare-commit-msg Pre-applypatch Pre-rebase

Page 32: DevOps: Cooking Drupal Deployment

DrushDrushis a command-line shell and scripting interface for Drupal, a veritable is a command-line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those who spend Swiss Army knife designed to make life easier for those who spend

their working hours hacking away at the command prompttheir working hours hacking away at the command prompt

Page 33: DevOps: Cooking Drupal Deployment

Drush:Drush: Clear CacheClear Cache

Command: $ drush cc all

Page 34: DevOps: Cooking Drupal Deployment

Drush:Drush: Run hook_updateRun hook_update

Command: $ drush updb -y $ drush @domain.prod updb -y

Page 35: DevOps: Cooking Drupal Deployment

Drush MakeDrush Make

Page 36: DevOps: Cooking Drupal Deployment

Drush:Drush: Make CapabilitiesMake Capabilities

Downloading Drupal core, as well as contrib modules from drupal.org. 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.

Page 37: DevOps: Cooking Drupal Deployment

Useful Drush Useful Drush CommandsCommands

not really important in deploymentnot really important in deployment

Page 38: DevOps: Cooking Drupal Deployment

Drush:Drush: SQL LoginSQL Login

Command:$ drush sql-cli

Page 39: DevOps: Cooking Drupal Deployment

Drush:Drush: SQL QuerySQL Query

Command:$ drush sqlq “UPDATE users SET pass=$S$DHaDeIifGS5qiS7ghhEolZ9lbaRTkZh/UcU.dhZY0Rpp1gUooEpQ WHERE uid=1”

Page 40: DevOps: Cooking Drupal Deployment

Drush: Drush: SQL SyncSQL Sync

Command:$ drush sql-sync @prod @dev

Page 41: DevOps: Cooking Drupal Deployment

Drush:Drush: SQL CreateSQL Create

Command:$ drush sql-create$ drush @domain.dev sql-create

Page 42: DevOps: Cooking Drupal Deployment

Drush:Drush: SQL DropSQL Drop

Command:$ drush sql-drop$ drush @domain.dev sql-drop

Page 43: DevOps: Cooking Drupal Deployment

Drush: Drush: SQL DumpSQL Dump Command:$ drush sql-dump --result-file=../bck.sql

Options:--gzip--result-file

Page 44: DevOps: Cooking Drupal Deployment

Drush:Drush: Variable SetVariable Set

Command:$ drush vset preprocess_js 1 -y

Page 45: DevOps: Cooking Drupal Deployment

Drush:Drush: Module EnableModule Enable

Command:$ drush en views -y$ drush en features views_ui -y

Page 46: DevOps: Cooking Drupal Deployment

Drush:Drush: Module DisableModule Disable

Command:$ drush dis views -y$ drush dis features views_ui -y

Page 47: DevOps: Cooking Drupal Deployment

Drush:Drush: Module UninstallModule Uninstall

Command:$ drush pm-uninstall views -y$ drush pm-uninstall ctools views -y

Page 48: DevOps: Cooking Drupal Deployment

Drush:Drush: One-time LoginOne-time Login

Command:$ drush uli gerald$ drush uli –browser=firefox [email protected]

Page 49: DevOps: Cooking Drupal Deployment

Drush:Drush: Update PasswordUpdate Password

Command:$ drush upwd gerald --password=foo

Page 50: DevOps: Cooking Drupal Deployment

Use Use Site AliasSite Alias

Allows you to execute Drush commands in target remote server via ssh

Command:$ drush @domain.prod updb -y

Page 51: DevOps: Cooking Drupal Deployment

FeaturesFeaturesEnables the capture and management of features in Drupal. A feature Enables the capture and management of features in Drupal. A feature

is a collection of Drupal entities which taken together satisfy a is a collection of Drupal entities which taken together satisfy a certain use-case.certain use-case.

Page 52: DevOps: Cooking Drupal Deployment

Features: Features: CreateCreate

Page 53: DevOps: Cooking Drupal Deployment

Features: Features: ManageManage

Page 54: DevOps: Cooking Drupal Deployment

Features: Features: ModuleModule

Page 55: DevOps: Cooking Drupal Deployment

Features: Features: Drush IntegrationDrush Integrationfeatures-revert-all (fra) Revert all enabled feature module on your site.

Command:drush fra -y

Options:--force

Page 56: DevOps: Cooking Drupal Deployment

BashBashA command processor, typically run in a text window, allowing the A command processor, typically run in a text window, allowing the

user to type commands which cause actions. Bash can also read user to type commands which cause actions. Bash can also read commands from a file, called a script. Like all Unix shells, it supports commands from a file, called a script. Like all Unix shells, it supports

filename wildcarding, piping, here documents, command filename wildcarding, piping, here documents, command substitution, variables and control structures for condition-testing substitution, variables and control structures for condition-testing

and iteration. and iteration. - Wikipedia- Wikipedia

Page 57: DevOps: Cooking Drupal Deployment
Page 58: DevOps: Cooking Drupal Deployment

Bash Scripting: Bash Scripting: SampleSample#!/usr/bin/env bashpath=”sites/all/default/files”if [ ! -d “$path”]; then mkdir $path chown www-data:www-data $path fi

Page 59: DevOps: Cooking Drupal Deployment

Bash Scripting: Bash Scripting: DrushDrush#!/usr/bin/env bashdrush cc alldrush updb -ydrush fra -ydrush cc allecho “Delployment done!”

Page 60: DevOps: Cooking Drupal Deployment

I don't know Bash!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.

Page 61: DevOps: Cooking Drupal Deployment

Drupal APIDrupal API

Page 62: DevOps: Cooking Drupal Deployment

hook_update_Nhook_update_N

Page 63: DevOps: Cooking Drupal Deployment

hook_update_N: hook_update_N: SampleSample/** * Enable Test module. */function test_update_7001() { $module = array('test'); module_enable($module);}

Page 64: DevOps: Cooking Drupal Deployment

DemoDemo

Page 65: DevOps: Cooking Drupal Deployment

What we What we achieved?achieved?

Page 66: DevOps: Cooking Drupal Deployment

We used Git to managed We used Git to managed the entire deployment.the entire deployment.

Page 67: DevOps: Cooking Drupal Deployment

We used Features to We used Features to capture database capture database

changes. changes.

Page 68: DevOps: Cooking Drupal Deployment

We used Drush to run the We used Drush to run the hook_update_N, revert hook_update_N, revert the features, and clear the features, and clear

the cache.the cache.

Page 69: DevOps: Cooking Drupal Deployment

We created a Bash script We created a Bash script that contains deployment that contains deployment

process run by Git.process run by Git.

Page 70: DevOps: Cooking Drupal Deployment

Related Related DevOps ToolsDevOps Tools

Page 71: DevOps: Cooking Drupal Deployment

PuppetPuppetOpen-souce automation software that helps system administrators Open-souce automation software that helps system administrators

manage infrastructure throughout its lifecycle, from provisioning and manage infrastructure throughout its lifecycle, from provisioning and configuration to orchestration and reporting.configuration to orchestration and reporting.

Page 72: DevOps: Cooking Drupal Deployment

ChefChefA systems and cloud infrastructure automation framework that A systems and cloud infrastructure automation framework that makes it easy to deploy servers and applications to any physical, makes it easy to deploy servers and applications to any physical, virtual, or cloud location, no matter the size of the infrastructure.virtual, or cloud location, no matter the size of the infrastructure.

Page 73: DevOps: Cooking Drupal Deployment

AnsibleAnsibleAnsible configures operating systems, deploys applications, runs Ansible configures operating systems, deploys applications, runs

parallel commands, and orchestrates IT processes like zero-downtime parallel commands, and orchestrates IT processes like zero-downtime rolling updates. It uses SSH by default, so no special software has to rolling updates. It uses SSH by default, so no special software has to

be installed to start managing remote machines. Modules can be be installed to start managing remote machines. Modules can be written in any language.written in any language.

Page 74: DevOps: Cooking Drupal Deployment

JujuJujuJuju is a powerful service orchestration tool from Ubuntu that helps Juju is a powerful service orchestration tool from Ubuntu that helps you define, configure and deploy services to any cloud quickly and you define, configure and deploy services to any cloud quickly and

easily.easily.

Page 75: DevOps: Cooking Drupal Deployment

CapistranoCapistranoCapistrano was originally designed to simplify and automate Capistrano was originally designed to simplify and automate deployment of web applications to distributed environments.deployment of web applications to distributed environments.

Page 76: DevOps: Cooking Drupal Deployment

DockerDockerDocker is an open-source project to easily create lightweight, Docker is an open-source project to easily create lightweight,

portable, self-sufficient containers from any application. The same portable, self-sufficient containers from any application. The same container that a developer builds and tests on a laptop can run at container that a developer builds and tests on a laptop can run at

scale, in production, on VMs, bare metal, OpenStack clusters, public scale, in production, on VMs, bare metal, OpenStack clusters, public clouds and more.clouds and more.

Page 77: DevOps: Cooking Drupal Deployment

ForemanForemanfor managing physical and virtual serverfor managing physical and virtual server

Page 78: DevOps: Cooking Drupal Deployment

Travis CITravis CIdistributed continuous integration service used to build and test distributed continuous integration service used to build and test

projectsprojects

Page 79: DevOps: Cooking Drupal Deployment

JenkinsJenkinsAn extendable open source continuous integration server. Built with An extendable open source continuous integration server. Built with Java, it provides 829 plugins to support building and testing virtually Java, it provides 829 plugins to support building and testing virtually

any project.any project.

Page 80: DevOps: Cooking Drupal Deployment

MavenMavenMaven allows a project to build using its project object model (POM) 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, and a set of plugins that are shared by all projects using Maven, providing a uniform build system.providing a uniform build system.

Page 81: DevOps: Cooking Drupal Deployment

rsyncrsyncIs a file transfer program for Unix systems. rsync uses the "rsync Is a file transfer program for Unix systems. rsync uses the "rsync

algorithm" which provides a very fast method for bringing remote algorithm" which provides a very fast method for bringing remote files into sync. It does this by sending just the differences in the files 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 across the link, without requiring that both sets of files are present

at one of the ends of the link beforehand.at one of the ends of the link beforehand.

Page 82: DevOps: Cooking Drupal Deployment

Questions?Questions?

Page 83: DevOps: Cooking Drupal Deployment

ResouresResoures http://devops.com http://devo.ps http://dev2ops.org http://devopsweekly.com http://devopsdays.org http://drush.ws http://try.github.io http://tldp.org/LDP/abs/html

Page 84: DevOps: Cooking Drupal Deployment

Contact DetailsContact Details

http://about.me/gerald.villorente

Page 85: DevOps: Cooking Drupal Deployment

10-26-1310-26-13