DEVOPS FOR HUMANS
F O R D R U P A L D E P L O Y M E N T V I C T O R Y !
DevOps Track - Thursday, June 5, 2014
2014
Me
• geerlingguy / Jeff Geerling
• Senior Application Developer, Mercy
• Owner, Midwestern Mac, LLC
Ansible for DevOps
• For sale on LeanPub
• 50% complete
This presentation
1. Drupal deployments are hard
2. Ansible is simple and powerful
3. Ansible is great for Drupal deployme...
In the Beginning…
• Local Dev: MAMP/WAMP/XAMPP
• Deployments: git	
  pull	
  &&	
  drush	
  updb	
  
• Plus 15 other manua...
http://devopsreactions.tumblr.com/
http://devopsreactions.tumblr.com/
 _______________________________________	
  	
  
/	
  I	
  once	
  had	
  to	
  go	
  to	
  a	
  sysadmin	
  with	
  a	
  ...
Managed servers: 1
Managed servers: 1
circa
(Dries)
Managed servers: 50+
UAT
Test
Prod
Managed servers: 50+
UAT
Test
Prod
Dev
Managed servers: 50+
UAT
Test
Prod
circa
Dev
The Simsons™ and © Fox and its related companies. All rights reserved.
DevOps
• Solving Modern Problems:
• multi-server infrastructure (beyond LAMP)
• cloud provisioning, auto-scaling
• testabl...
 _______________________________________	
  	
  
/	
  It	
  should	
  take	
  less	
  time	
  to	
  rebuild	
  a	
  	
  
	...
Puppet Chef Salt Ansible
Initial release 2005 2009 2011 2012
Configuration
Language DSL Ruby/DSL YAML YAML
Template
Languag...
Puppet Chef Salt Ansible
Initial release 2005 2009 2011 2012
Configuration
Language DSL Ruby/DSL YAML YAML
Template
Languag...
Puppet Chef Salt Ansible
Initial release 2005 2009 2011 2012
Configuration
Language DSL Ruby/DSL YAML YAML
Template
Languag...
Who uses ?
(and me: Server Check.in, Hosted Apache Solr, Midwestern Mac, LLC)
First Steps with
Inventory
Inventory
[lamp]	
  
example.com	
  
!
[lamp:vars]	
  
ansible_ssh_user=johndoe	
  
ansible_ssh_port=2222
(save in /etc/an...
Inventory
[lamp]	
  
example.com	
  
!
[lamp:vars]	
  
ansible_ssh_user=johndoe	
  
ansible_ssh_port=2222
(save in /etc/an...
Inventory
[lamp]	
  
example.com	
  
!
[lamp:vars]	
  
ansible_ssh_user=johndoe	
  
ansible_ssh_port=2222
(save in /etc/an...
Inventory
[lamp]	
  
example.com	
  
!
[lamp:vars]	
  
ansible_ssh_user=johndoe	
  
ansible_ssh_port=2222
(save in /etc/an...
Playbook Task
Playbook Task
-­‐	
  name:	
  Ensure	
  Apache	
  is	
  installed.	
  
	
  	
  apt:	
  pkg=apache2	
  state=latest
Playbook Task
-­‐	
  name:	
  Ensure	
  Apache	
  is	
  installed.	
  
	
  	
  apt:	
  pkg=apache2	
  state=latest
Documen...
Playbook Task
-­‐	
  name:	
  Ensure	
  Apache	
  is	
  installed.	
  
	
  	
  apt:	
  pkg=apache2	
  state=latest
Documen...
Playbook Task
-­‐	
  name:	
  Ensure	
  Apache	
  is	
  installed.	
  
	
  	
  apt:	
  pkg=apache2	
  state=latest
Documen...
Playbook
-­‐-­‐-­‐	
  
-­‐	
  name:	
  Ensure	
  Apache/PHP	
  is	
  installed.	
  
	
  	
  apt:	
  "pkg={{	
  item	
  }}	...
Playbook
-­‐-­‐-­‐	
  
-­‐	
  hosts:	
  lamp	
  
	
  	
  sudo:	
  yes	
  
!
	
  	
  tasks:	
  
	
  	
  	
  	
  -­‐	
  apt:...
Playbook
-­‐-­‐-­‐	
  
-­‐	
  hosts:	
  lamp	
  
	
  	
  sudo:	
  yes	
  
!
	
  	
  tasks:	
  
	
  	
  	
  	
  -­‐	
  apt:...
Playbook
-­‐-­‐-­‐	
  
-­‐	
  hosts:	
  lamp	
  
	
  	
  sudo:	
  yes	
  
!
	
  	
  tasks:	
  
	
  	
  	
  	
  -­‐	
  apt:...
ansible-­‐playbook run
ansible-­‐playbook run
Ansible ♥ Vagrant
Ansible ♥ Vagrant
• First-class provisioner
• Inside Vagrantfile:
	
  	
  	
  	
  config.vm.provision	
  "ansible"	
  do	
 ...
Deploy Drupal 8 with
-­‐-­‐-­‐	
  
-­‐	
  hosts:	
  d8	
  
	
  	
  sudo:	
  yes	
  
!
	
  	
  pre_tasks:	
  
	
  	
  	
  	
  -­‐	
  apt:	
  upd...
-­‐-­‐-­‐	
  
-­‐	
  
	
  	
  
!
	
  	
  
	
  	
  	
  	
  -­‐	
  
	
  	
  	
  	
  -­‐	
  
	
  	
  	
  	
  	
  	
  	
  	
  ...
00:03:14 later…
Demo
Ansible Roles
• Encapsulation for configuration/tasks
Ansible Roles
• Encapsulation for configuration/tasks
Ansible Role
files/
tasks/
handlers/
vars/ meta/
templates/
Drupal Deployment Role
deploy/
roles/
site-deploy/
playbook.yml
Drupal Deployment Role
deploy/
roles/
site-deploy/
playbook.yml
Custom role!
'site-deploy'
tasks
-­‐-­‐-­‐	
  
-­‐	
  name:	
  Run	
  drush	
  commands	
  to	
  update	
  site.	
  
	
  	
  command:	
  >	
  
	
  	
...
vars
-­‐-­‐-­‐	
  
site_name:	
  "Ansible	
  Deployment"	
  
drupal_core_path:	
  /var/www/drupal-­‐8.x-­‐dev
site-deploy/...
handlers
-­‐-­‐-­‐	
  
-­‐	
  name:	
  restart	
  webserver	
  
	
  	
  service:	
  >	
  
	
  	
  	
  	
  name=apache2	
  ...
deploy/
roles/
site-deploy/
playbook.yml
tasks/main.yml
vars/main.yml
handlers/main.yml
Drupal Deployment Role
deploy/
roles/
site-deploy/
playbook.yml
Drupal Deployment Role
playbook
-­‐-­‐-­‐	
  
-­‐	
  hosts:	
  d8	
  
	
  	
  roles:	
  
	
  	
  	
  	
  -­‐	
  site-­‐deploy
playbook.yml
Demo
Notifications
-­‐	
  name:	
  Send	
  IRC	
  message.	
  
	
  	
  irc:	
  >	
  
	
  	
  	
  	
  channel='#drupalcon'	
  
	
...
-­‐-­‐-­‐	
  
-­‐	
  hosts:	
  d8	
  
	
  	
  sudo:	
  yes	
  
!
	
  	
  pre_tasks:	
  
	
  	
  	
  	
  -­‐	
  apt:	
  upd...
-­‐-­‐-­‐	
  
-­‐	
  hosts:	
  d8	
  
	
  	
  sudo:	
  yes	
  
!
	
  	
  pre_tasks:	
  
	
  	
  	
  	
  -­‐	
  apt:	
  upd...
reverse-proxy.yml
webserver.yml
database.yml
search.yml
cache.yml
reverse-proxy.yml
webserver.yml
database.yml
search.yml
cache.yml
infrastructure-playbook.yml
-­‐-­‐-­‐	
  
-­‐	
  hosts:	
  all	
  
	
  	
  roles:	
  
	
  	
  	
  	
  -­‐	
  security	
  
	
  	
  	
  	
  -­‐	
  monit...
for Drupal
Deployment Victory!
for Drupal
Deployment Victory!
• Easy to get started
for Drupal
Deployment Victory!
• Easy to get started
• OH: “it works on my machine”
• sysadmin burnout
for Drupal
Deployment Victory!
• Easy to get started
• OH: “it works on my machine”
• sysadmin burnout
• You’ll actually e...
for Drupal
Deployment Victory!
• Easy to get started
• OH: “it works on my machine”
• sysadmin burnout
• You’ll actually e...
Things I wanted to cover,
but didn’t have time
• Ansible ♥’s:
• Packer
• Docker
• [AWS|DO|Linode|Rackspace|etc.]
Things I wanted to cover,
but didn’t have time
• Ansible ♥’s:
• Packer
• Docker
• [AWS|DO|Linode|Rackspace|etc.]
• Delegation, notifications, ad-hoc commands, async
comma...
Resources
• Docs
• Freenode: #ansible
• Google Group
• Ansible for DevOps
• Ansible Weekly (newsletter)
• Download Ansible
• Automate!
• Buy my book :)
Things you will do now:
WHAT DID YOU THINK?
EVALUATE THIS SESSI ON:
AUSTIN2014.DRUPAL.ORG/SCH ED ULE
Thank you!
2014
DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!
Upcoming SlideShare
Loading in...5
×

DevOps for Humans - Ansible for Drupal Deployment Victory!

5,843

Published on

Everyone knows it's a Good Idea™ to use a configuration management system (e.g. Puppet, Chef) to manage your Drupal infrastructure. But many people (myself included) have run into a wall of #wtfmoments when trying to learn the vagaries of traditional CM systems and their vendor-specific syntaxes.

In 2012, Ansible was released, enabling normal human beings to manage their servers with an easy, but powerful, CM system that uses YAML (just like Drupal 8!) to define configuration and Jinja2 (very much like Twig!) for templates. Not only that, but Ansible is also an incredibly simple and very flexible Drupal deployment and continuous delivery tool.

Learn how you can use Ansible to manage your infrastructure—including local development environments—and stop letting servers and deployments get in the way of development.

Published in: Software, Technology
0 Comments
11 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,843
On Slideshare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
77
Comments
0
Likes
11
Embeds 0
No embeds

No notes for slide

DevOps for Humans - Ansible for Drupal Deployment Victory!

  1. 1. DEVOPS FOR HUMANS F O R D R U P A L D E P L O Y M E N T V I C T O R Y ! DevOps Track - Thursday, June 5, 2014 2014
  2. 2. Me • geerlingguy / Jeff Geerling • Senior Application Developer, Mercy • Owner, Midwestern Mac, LLC
  3. 3. Ansible for DevOps • For sale on LeanPub • 50% complete
  4. 4. This presentation 1. Drupal deployments are hard 2. Ansible is simple and powerful 3. Ansible is great for Drupal deployments
 (and a lot more)
  5. 5. In the Beginning… • Local Dev: MAMP/WAMP/XAMPP • Deployments: git  pull  &&  drush  updb   • Plus 15 other manual deployment steps… • New servers: manual provisioning
  6. 6. http://devopsreactions.tumblr.com/
  7. 7. http://devopsreactions.tumblr.com/
  8. 8.  _______________________________________     /  I  once  had  to  go  to  a  sysadmin  with  a      bottle  of  whiskey  to  get  a  deploy.        /    -­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐                          ^__^                        (oo)_______                          (__)              )/                                  ||-­‐-­‐-­‐-­‐w  |                                  ||          || @itababy at AnsibleFest NYC, 2014
  9. 9. Managed servers: 1
  10. 10. Managed servers: 1 circa (Dries)
  11. 11. Managed servers: 50+ UAT Test Prod
  12. 12. Managed servers: 50+ UAT Test Prod Dev
  13. 13. Managed servers: 50+ UAT Test Prod circa Dev
  14. 14. The Simsons™ and © Fox and its related companies. All rights reserved.
  15. 15. DevOps • Solving Modern Problems: • multi-server infrastructure (beyond LAMP) • cloud provisioning, auto-scaling • testable infrastructure
  16. 16.  _______________________________________     /  It  should  take  less  time  to  rebuild  a      server  than  to  log  in  and  fix  it.          /    -­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐                          ^__^                        (oo)_______                          (__)              )/                                  ||-­‐-­‐-­‐-­‐w  |                                  ||          || http://www.slideshare.net/ItamarHassin/monitordriven-development-using-ansible-34920480
  17. 17. Puppet Chef Salt Ansible Initial release 2005 2009 2011 2012 Configuration Language DSL Ruby/DSL YAML YAML Template Language ERB ERB Jinja2 Jinja2 Agentless ✓ Simple ad-hoc task execution ✓ ✓ GitHub ★s* 2,239 2,729 3,531 6,202 *As of 2014/06/02. Just a reference point. Stars don’t mean much in the grand scheme of things ;-) Current solutions
  18. 18. Puppet Chef Salt Ansible Initial release 2005 2009 2011 2012 Configuration Language DSL Ruby/DSL YAML YAML Template Language ERB ERB Jinja2 Jinja2 Agentless ✓ Simple ad-hoc task execution ✓ ✓ GitHub ★s* 2,239 2,729 3,531 6,202 Just like Drupal 8! Just like Twig! *As of 2014/06/02. Just a reference point. Stars don’t mean much in the grand scheme of things ;-) Current solutions
  19. 19. Puppet Chef Salt Ansible Initial release 2005 2009 2011 2012 Configuration Language DSL Ruby/DSL YAML YAML Template Language ERB ERB Jinja2 Jinja2 Agentless ✓ Simple ad-hoc task execution ✓ ✓ GitHub ★s* 2,239 2,729 3,531 6,202 Just like Drupal 8! Just like Twig! *As of 2014/06/02. Just a reference point. Stars don’t mean much in the grand scheme of things ;-) #HugOps Current solutions
  20. 20. Who uses ? (and me: Server Check.in, Hosted Apache Solr, Midwestern Mac, LLC)
  21. 21. First Steps with
  22. 22. Inventory
  23. 23. Inventory [lamp]   example.com   ! [lamp:vars]   ansible_ssh_user=johndoe   ansible_ssh_port=2222 (save in /etc/ansible/hosts)
  24. 24. Inventory [lamp]   example.com   ! [lamp:vars]   ansible_ssh_user=johndoe   ansible_ssh_port=2222 (save in /etc/ansible/hosts) Group name
  25. 25. Inventory [lamp]   example.com   ! [lamp:vars]   ansible_ssh_user=johndoe   ansible_ssh_port=2222 (save in /etc/ansible/hosts) Group name Hosts in group (just one, for now)
  26. 26. Inventory [lamp]   example.com   ! [lamp:vars]   ansible_ssh_user=johndoe   ansible_ssh_port=2222 (save in /etc/ansible/hosts) Group name Hosts in group (just one, for now) Variables
 (for all hosts in group)
  27. 27. Playbook Task
  28. 28. Playbook Task -­‐  name:  Ensure  Apache  is  installed.      apt:  pkg=apache2  state=latest
  29. 29. Playbook Task -­‐  name:  Ensure  Apache  is  installed.      apt:  pkg=apache2  state=latest Documentation
  30. 30. Playbook Task -­‐  name:  Ensure  Apache  is  installed.      apt:  pkg=apache2  state=latest Documentation Module
  31. 31. Playbook Task -­‐  name:  Ensure  Apache  is  installed.      apt:  pkg=apache2  state=latest Documentation Arguments Module
  32. 32. Playbook -­‐-­‐-­‐   -­‐  name:  Ensure  Apache/PHP  is  installed.      apt:  "pkg={{  item  }}  state=latest"      with_items:          -­‐  apache2          -­‐  php5-­‐common          -­‐  libapache2-­‐mod-­‐php5          -­‐  php5-­‐cli   ! -­‐  name:  Ensure  Apache  is  started.      service:  name=apache2  state=started (save as web.yml)
  33. 33. Playbook -­‐-­‐-­‐   -­‐  hosts:  lamp      sudo:  yes   !    tasks:          -­‐  apt:  update_cache=yes   !        -­‐  include:  web.yml (save as playbook.yml)
  34. 34. Playbook -­‐-­‐-­‐   -­‐  hosts:  lamp      sudo:  yes   !    tasks:          -­‐  apt:  update_cache=yes   !        -­‐  include:  web.yml (save as playbook.yml) Name of group/host defined in inventory
  35. 35. Playbook -­‐-­‐-­‐   -­‐  hosts:  lamp      sudo:  yes   !    tasks:          -­‐  apt:  update_cache=yes   !        -­‐  include:  web.yml (save as playbook.yml) Name of group/host defined in inventory Include the playbook we created earlier
  36. 36. ansible-­‐playbook run
  37. 37. ansible-­‐playbook run
  38. 38. Ansible ♥ Vagrant
  39. 39. Ansible ♥ Vagrant • First-class provisioner • Inside Vagrantfile:        config.vm.provision  "ansible"  do  |ansible|
              ansible.playbook  =  "playbook.yml"
              ansible.inventory_path  =  "inventory-­‐vagrant"
        end
  40. 40. Deploy Drupal 8 with
  41. 41. -­‐-­‐-­‐   -­‐  hosts:  d8      sudo:  yes   !    pre_tasks:          -­‐  apt:  update_cache=yes          -­‐  apt_repository:  >                  repo='ppa:ondrej/php5-­‐oldstable'   !    roles:          -­‐  geerlingguy.apache          -­‐  geerlingguy.mysql          -­‐  geerlingguy.php          -­‐  geerlingguy.php-­‐mysql          -­‐  geerlingguy.postfix          -­‐  geerlingguy.drupal
  42. 42. -­‐-­‐-­‐   -­‐       !            -­‐          -­‐                  repo='ppa:ondrej/php5-­‐oldstable' !            -­‐          -­‐          -­‐          -­‐          -­‐          -­‐   (this actually works)
  43. 43. 00:03:14 later…
  44. 44. Demo
  45. 45. Ansible Roles • Encapsulation for configuration/tasks
  46. 46. Ansible Roles • Encapsulation for configuration/tasks Ansible Role files/ tasks/ handlers/ vars/ meta/ templates/
  47. 47. Drupal Deployment Role deploy/ roles/ site-deploy/ playbook.yml
  48. 48. Drupal Deployment Role deploy/ roles/ site-deploy/ playbook.yml Custom role! 'site-deploy'
  49. 49. tasks -­‐-­‐-­‐   -­‐  name:  Run  drush  commands  to  update  site.      command:  >          drush  -­‐y  {{  item  }}          chdir={{  drupal_core_path  }}      with_items:            -­‐  "cset  system.site  name  '{{  site_name  }}'"          -­‐  "rap  'anonymous'  'search  content'"      notify:  restart  webserver site-deploy/tasks/main.yml
  50. 50. vars -­‐-­‐-­‐   site_name:  "Ansible  Deployment"   drupal_core_path:  /var/www/drupal-­‐8.x-­‐dev site-deploy/vars/main.yml
  51. 51. handlers -­‐-­‐-­‐   -­‐  name:  restart  webserver      service:  >          name=apache2          state=restarted      sudo:  yes site-deploy/handlers/main.yml
  52. 52. deploy/ roles/ site-deploy/ playbook.yml tasks/main.yml vars/main.yml handlers/main.yml Drupal Deployment Role
  53. 53. deploy/ roles/ site-deploy/ playbook.yml Drupal Deployment Role
  54. 54. playbook -­‐-­‐-­‐   -­‐  hosts:  d8      roles:          -­‐  site-­‐deploy playbook.yml
  55. 55. Demo
  56. 56. Notifications -­‐  name:  Send  IRC  message.      irc:  >          channel='#drupalcon'          server='chat.freenode.net'          nick='ansible-­‐ninja'          msg={{  irc_message  }}      delegate_to:  127.0.0.1 (also inside playbook.yml)
  57. 57. -­‐-­‐-­‐   -­‐  hosts:  d8      sudo:  yes   !    pre_tasks:          -­‐  apt:  update_cache=yes          -­‐  apt_repository:  >                  repo='ppa:ondrej/php5-­‐oldstable'   !    roles:          -­‐  geerlingguy.apache          -­‐  geerlingguy.mysql          -­‐  geerlingguy.php          -­‐  geerlingguy.php-­‐mysql          -­‐  geerlingguy.postfix          -­‐  geerlingguy.drupal          -­‐  site-­‐deploy
  58. 58. -­‐-­‐-­‐   -­‐  hosts:  d8      sudo:  yes   !    pre_tasks:          -­‐  apt:  update_cache=yes          -­‐  apt_repository:  >                  repo='ppa:ondrej/php5-­‐oldstable'   !    roles:          -­‐  geerlingguy.apache          -­‐  geerlingguy.mysql          -­‐  geerlingguy.php          -­‐  geerlingguy.php-­‐mysql          -­‐  geerlingguy.postfix          -­‐  geerlingguy.drupal          -­‐  site-­‐deploy Add to provisioning
 playbook.yml
  59. 59. reverse-proxy.yml webserver.yml database.yml search.yml cache.yml
  60. 60. reverse-proxy.yml webserver.yml database.yml search.yml cache.yml infrastructure-playbook.yml
  61. 61. -­‐-­‐-­‐   -­‐  hosts:  all      roles:          -­‐  security          -­‐  monitoring          -­‐  fileshare   ! -­‐  hosts:  webservers      roles:          -­‐  nginx          -­‐  php          -­‐  drupal   ! -­‐  hosts:  database      roles:          -­‐  postgres
  62. 62. for Drupal Deployment Victory!
  63. 63. for Drupal Deployment Victory! • Easy to get started
  64. 64. for Drupal Deployment Victory! • Easy to get started • OH: “it works on my machine” • sysadmin burnout
  65. 65. for Drupal Deployment Victory! • Easy to get started • OH: “it works on my machine” • sysadmin burnout • You’ll actually enjoy it!
  66. 66. for Drupal Deployment Victory! • Easy to get started • OH: “it works on my machine” • sysadmin burnout • You’ll actually enjoy it! • …but BEWARE THE GOLDEN HAMMER!
  67. 67. Things I wanted to cover, but didn’t have time
  68. 68. • Ansible ♥’s: • Packer • Docker • [AWS|DO|Linode|Rackspace|etc.] Things I wanted to cover, but didn’t have time
  69. 69. • Ansible ♥’s: • Packer • Docker • [AWS|DO|Linode|Rackspace|etc.] • Delegation, notifications, ad-hoc commands, async commands, rolling updates, prompts, Ansible Vault, wait_for, forks, dynamic inventory, and oh-so-much-more… Things I wanted to cover, but didn’t have time
  70. 70. Resources • Docs • Freenode: #ansible • Google Group • Ansible for DevOps • Ansible Weekly (newsletter)
  71. 71. • Download Ansible • Automate! • Buy my book :) Things you will do now:
  72. 72. WHAT DID YOU THINK? EVALUATE THIS SESSI ON: AUSTIN2014.DRUPAL.ORG/SCH ED ULE Thank you! 2014
  1. Gostou de algum slide específico?

    Recortar slides é uma maneira fácil de colecionar informações para acessar mais tarde.

×