DevOps for Humans - Ansible for Drupal Deployment Victory!

Click here to load reader

download DevOps for Humans - Ansible for Drupal Deployment Victory!

of 74

  • date post

    27-Aug-2014
  • Category

    Software

  • view

    1.884
  • download

    5

Embed Size (px)

description

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.

Transcript of DevOps for Humans - Ansible for Drupal Deployment Victory!

  • 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 deployments (and a lot more)
  • In the Beginning Local Dev: MAMP/WAMP/XAMPP Deployments: git pull && drush updb Plus 15 other manual deployment steps New servers: manual provisioning
  • http://devopsreactions.tumblr.com/
  • http://devopsreactions.tumblr.com/
  • _______________________________________ / I once had to go to a sysadmin with a bottle of whiskey to get a deploy. / --------------------------------------- ^__^ (oo)_______ (__) )/ ||----w | || || @itababy at AnsibleFest NYC, 2014
  • 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 testable infrastructure
  • _______________________________________ / 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
  • Puppet Chef Salt Ansible Initial release 2005 2009 2011 2012 Conguration 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 dont mean much in the grand scheme of things ;-) Current solutions
  • Puppet Chef Salt Ansible Initial release 2005 2009 2011 2012 Conguration 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 dont mean much in the grand scheme of things ;-) Current solutions
  • Puppet Chef Salt Ansible Initial release 2005 2009 2011 2012 Conguration 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 dont mean much in the grand scheme of things ;-) #HugOps Current solutions
  • 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/ansible/hosts)
  • Inventory [lamp] example.com ! [lamp:vars] ansible_ssh_user=johndoe ansible_ssh_port=2222 (save in /etc/ansible/hosts) Group name
  • 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)
  • 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)
  • 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 Documentation
  • Playbook Task - name: Ensure Apache is installed. apt: pkg=apache2 state=latest Documentation Module
  • Playbook Task - name: Ensure Apache is installed. apt: pkg=apache2 state=latest Documentation Arguments Module
  • 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)
  • Playbook --- - hosts: lamp sudo: yes ! tasks: - apt: update_cache=yes ! - include: web.yml (save as playbook.yml)
  • Playbook --- - hosts: lamp sudo: yes ! tasks: - apt: update_cache=yes ! - include: web.yml (save as playbook.yml) Name of group/host dened in inventory
  • Playbook --- - hosts: lamp sudo: yes ! tasks: - apt: update_cache=yes ! - include: web.yml (save as playbook.yml) Name of group/host dened in inventory Include the playbook we created earlier
  • ansible-playbook run
  • ansible-playbook run
  • Ansible Vagrant
  • Ansible Vagrant First-class provisioner Inside Vagrantle: config.vm.provision "ansible" do |ansible| ansible.playbook = "playbook.yml" ansible.inventory_path = "inventory-vagrant" end
  • Deploy Drupal 8 with
  • --- - 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
  • --- - ! - - repo='ppa:ondrej/php5-oldstable' ! - - - - - - (this actually works)
  • 00:03:14 later
  • Demo
  • Ansible Roles Encapsulation for conguration/tasks
  • Ansible Roles Encapsulation for conguration/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: > drush -y {{ item }} chdir={{ drupal_core_path }} with_items: - "cset system.site name '{{ site_name }}'" - "rap 'anonymous'