Top Banner
Ansible + Drupal A fortuitous DevOps Match #MidCamp 2015 JeGeerling Technical Architect, Acquia ________________________________________ / "Automation shouldn't be your day job" \ \ #ansible #pycon2014 / ---------------------------------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||
43
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Ansible + Drupal: A Fortuitous DevOps Match

Ansible + DrupalA fortuitous DevOps Match

#MidCamp 2015 Jeff GeerlingTechnical Architect, Acquia

________________________________________ / "Automation shouldn't be your day job" \\ #ansible #pycon2014 / ---------------------------------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||

Page 2: Ansible + Drupal: A Fortuitous DevOps Match

Who am I?Jeff Geerling (geerlingguy)Technical Architect, AcquiaOwner, Midwestern Mac LLCDev (mainly)

Page 3: Ansible + Drupal: A Fortuitous DevOps Match

Ansible for DevOpsOn LeanPubNearly complete!50% off: http://bit.ly/midcamp-a4d

Page 4: Ansible + Drupal: A Fortuitous DevOps Match

ProblemsGrowing infrastructure.Drupal deployments are complex.More deployments, more downtime.<insert your problem here>

Page 5: Ansible + Drupal: A Fortuitous DevOps Match

“Configuration management for humans.” (— Me, 2014)Uses SSHSecure, fast, simple

Don't need configuration management to manage your configuration management.

Page 6: Ansible + Drupal: A Fortuitous DevOps Match

Over 270 modules built-in

Over 3,000 roles on Ansible Galaxy

Extensible, modular APIs (JSON, language-agnostic)

Page 7: Ansible + Drupal: A Fortuitous DevOps Match

InstallationMac: brew install ansible

Python pip: sudo pip install ansible

RHEL/CentOS: sudo yum install ansible

Deb/Ubuntu: sudo apt-add-repository ppa:ansible/ansible sudo apt-get update sudo apt-get install ansible

Page 8: Ansible + Drupal: A Fortuitous DevOps Match

Ansible 1011. Inventory: Describe your infrastructure

2. Ad-Hoc commands: Run one-off tasks

3. Playbooks: "Infrastructure as code"

Page 9: Ansible + Drupal: A Fortuitous DevOps Match

________________________________________ / Drupal 8 on a cluster of Raspberry Pis \\ #dramble / ---------------------------------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||

Page 10: Ansible + Drupal: A Fortuitous DevOps Match

http://robmyers.org/cc-ironies/no_flash_photography_sign/

Please help me avoid the Xenon Death Flash

Page 11: Ansible + Drupal: A Fortuitous DevOps Match

The #Dramble

CPU 24 cores / 5.4 GHz

RAM 6 GB

Storage 96 GB microSD

Network 10/100 over Gigabit network

Page 12: Ansible + Drupal: A Fortuitous DevOps Match
Page 13: Ansible + Drupal: A Fortuitous DevOps Match

InventoryLike a hosts file for Ansible (/etc/ansible/hosts)

INI syntax

[webservers]www1.pidramble.comwww2.pidramble.comwww3.pidramble.com

Page 14: Ansible + Drupal: A Fortuitous DevOps Match

InventoryLike a hosts file for Ansible (/etc/ansible/hosts)

INI syntax

[webservers]www1.pidramble.comwww2.pidramble.comwww3.pidramble.com

Group

Servers in group

Page 15: Ansible + Drupal: A Fortuitous DevOps Match

Ad-Hoc commandsTest Ansible's connection with the ping module.

$ ansible webservers -m ping

Page 16: Ansible + Drupal: A Fortuitous DevOps Match

Ad-Hoc commandsTest Ansible's connection with the ping module.

$ ansible webservers -m ping

Group

Module

Page 17: Ansible + Drupal: A Fortuitous DevOps Match
Page 18: Ansible + Drupal: A Fortuitous DevOps Match
Page 19: Ansible + Drupal: A Fortuitous DevOps Match

Ad-Hoc commandsHave fun with RGB LEDs!

$ ansible webservers -a "rgb red" -s

Page 20: Ansible + Drupal: A Fortuitous DevOps Match

Ad-Hoc commandsHave fun with RGB LEDs!

$ ansible webservers -a "rgb red" -s

Group

'Use sudo'

Command

Page 21: Ansible + Drupal: A Fortuitous DevOps Match

________< Shiny! > -------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||

Page 22: Ansible + Drupal: A Fortuitous DevOps Match

Ad-Hoc commands

$ ansible webservers -a "sudo apt-get install php5-common"

Page 23: Ansible + Drupal: A Fortuitous DevOps Match

Ad-Hoc commands

$ ansible webservers -m apt -a "name=php5-common state=installed" -s

Module Arguments

Page 24: Ansible + Drupal: A Fortuitous DevOps Match

PlaybooksAd-Hoc commands don't solve the snowflake problem

"infrastructure as code"Simple YAML filesRun with: ansible-playbook

Unique, by Pen Waggener

Page 25: Ansible + Drupal: A Fortuitous DevOps Match

Playbooks---- hosts: webservers sudo: yes

tasks: - name: Ensure PHP is installed. apt: name=php5-common state=installed

Page 26: Ansible + Drupal: A Fortuitous DevOps Match

Playbooks---- hosts: webservers sudo: yes

tasks: - name: Ensure PHP is installed. apt: name=php5-common state=installed

Group

Module

Documentation

Arguments

Page 27: Ansible + Drupal: A Fortuitous DevOps Match

PlaybooksIncludes: include playbooks in other playbooks

Variables: flexible - defaults and easy overrides

Templates: use Jinja2 (Twig-like syntax!)

Roles: encapsulate 'chunks' of configuration (like PHP classes)

Page 28: Ansible + Drupal: A Fortuitous DevOps Match

Back to the #Dramble

“Drupal 8 on a cluster of Raspberry Pis”

Page 29: Ansible + Drupal: A Fortuitous DevOps Match

Architecture

Page 30: Ansible + Drupal: A Fortuitous DevOps Match

Architecture

Page 31: Ansible + Drupal: A Fortuitous DevOps Match

Architecture

Page 32: Ansible + Drupal: A Fortuitous DevOps Match

Architecture

Page 33: Ansible + Drupal: A Fortuitous DevOps Match

Architecture---- hosts: database sudo: yes

vars_files: - ../vars.yml - vars.yml

roles: - geerlingguy.firewall - geerlingguy.mysql - geerlingguy.munin-node - ../roles/leds

Fully functioning MySQL server in 13 lines of YAML!

Page 34: Ansible + Drupal: A Fortuitous DevOps Match

Provisioning the ServersNo live demo: "Never rely on Conference WiFi"But we can talk about it later :-)

Page 35: Ansible + Drupal: A Fortuitous DevOps Match

Deploying Drupal 8

Demo

See: raspberry-pi-dramble on GitHub

Page 36: Ansible + Drupal: A Fortuitous DevOps Match

Deploying Drupal 81. First deploy: install$ ansible-playbook main.yml

2. Second deploy: update, import config, rebuild caches$ ansible-playbook main.yml --extra-vars "drupal_version=1.1.1"

3. Third deploy: enable Redis$ ansible-playbook main.yml --extra-vars "drupal_version=1.1.1 drupal_redis_enabled=true"

Page 37: Ansible + Drupal: A Fortuitous DevOps Match
Page 38: Ansible + Drupal: A Fortuitous DevOps Match

$ wrk -t4 -c100 -d20 http://pidramble.com/Running 20s test @ http://pidramble.com/ 4 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev Latency 45.19ms 21.19ms 350.10ms 89.04% Req/Sec 555.98 43.24 804.00 92.67% 44183 requests in 20.00s, 222.31MB readRequests/sec: 2209.20Transfer/sec: 11.12MB

$ wrk -t4 -c24 -d20 http://pidramble.com/?nocache=trueRunning 20s test @ http://pidramble.com/?nocache=true 4 threads and 24 connections Thread Stats Avg Stdev Max +/- Stdev Latency 1.62s 240.73ms 2.16s 63.33% Req/Sec 3.10 0.61 4.00 63.33% 288 requests in 20.03s, 1.45MB read Socket errors: connect 0, read 0, write 0, timeout 10Requests/sec: 14.38Transfer/sec: 73.89KB

Cached req/s: 2209.20

Uncached req/s: 14.38

Page 39: Ansible + Drupal: A Fortuitous DevOps Match

____________________________________/ Drupal 8 is scalable, but not fast \\ ...yet. / ------------------------------------ \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||

Page 40: Ansible + Drupal: A Fortuitous DevOps Match

MORE DRAMBLE!Tons of benchmarksD8 performance and deployment discoverySee the Raspberry Pi Dramble Wiki

Page 41: Ansible + Drupal: A Fortuitous DevOps Match

MORE ANSIBLE!Docker integrationAWS, DigitalOcean, Rackspace, Softlayer, Linode, etc.NotificationsRolling updatesAnsible VaultDynamic inventoryetc...

Page 42: Ansible + Drupal: A Fortuitous DevOps Match

Resources•Ansible documentation•Ansible Vagrant examples•Ansible for DevOps•Raspberry Pi Dramble

Page 43: Ansible + Drupal: A Fortuitous DevOps Match

Feedback• https://joind.in/13825•Speaker name: @geerlingguy• #MidCamp• #Dramble

50% off Ansible or DevOps:http://bit.ly/midcamp-a4d