Page 1
Ansible + DrupalA fortuitous DevOps Match
#MidCamp 2015 Jeff GeerlingTechnical Architect, Acquia
________________________________________ / "Automation shouldn't be your day job" \\ #ansible #pycon2014 / ---------------------------------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||
Page 2
Who am I?Jeff Geerling (geerlingguy)Technical Architect, AcquiaOwner, Midwestern Mac LLCDev (mainly)
Page 3
Ansible for DevOpsOn LeanPubNearly complete!50% off: http://bit.ly/midcamp-a4d
Page 4
ProblemsGrowing infrastructure.Drupal deployments are complex.More deployments, more downtime.<insert your problem here>
Page 5
“Configuration management for humans.” (— Me, 2014)Uses SSHSecure, fast, simple
Don't need configuration management to manage your configuration management.
Page 6
Over 270 modules built-in
Over 3,000 roles on Ansible Galaxy
Extensible, modular APIs (JSON, language-agnostic)
Page 7
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 1011. Inventory: Describe your infrastructure
2. Ad-Hoc commands: Run one-off tasks
3. Playbooks: "Infrastructure as code"
Page 9
________________________________________ / Drupal 8 on a cluster of Raspberry Pis \\ #dramble / ---------------------------------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||
Page 10
http://robmyers.org/cc-ironies/no_flash_photography_sign/
Please help me avoid the Xenon Death Flash
Page 11
The #Dramble
CPU 24 cores / 5.4 GHz
RAM 6 GB
Storage 96 GB microSD
Network 10/100 over Gigabit network
Page 13
InventoryLike a hosts file for Ansible (/etc/ansible/hosts)
INI syntax
[webservers]www1.pidramble.comwww2.pidramble.comwww3.pidramble.com
Page 14
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
Ad-Hoc commandsTest Ansible's connection with the ping module.
$ ansible webservers -m ping
Page 16
Ad-Hoc commandsTest Ansible's connection with the ping module.
$ ansible webservers -m ping
Group
Module
Page 19
Ad-Hoc commandsHave fun with RGB LEDs!
$ ansible webservers -a "rgb red" -s
Page 20
Ad-Hoc commandsHave fun with RGB LEDs!
$ ansible webservers -a "rgb red" -s
Group
'Use sudo'
Command
Page 21
________< Shiny! > -------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||
Page 22
Ad-Hoc commands
$ ansible webservers -a "sudo apt-get install php5-common"
Page 23
Ad-Hoc commands
$ ansible webservers -m apt -a "name=php5-common state=installed" -s
Module Arguments
Page 24
PlaybooksAd-Hoc commands don't solve the snowflake problem
"infrastructure as code"Simple YAML filesRun with: ansible-playbook
Unique, by Pen Waggener
Page 25
Playbooks---- hosts: webservers sudo: yes
tasks: - name: Ensure PHP is installed. apt: name=php5-common state=installed
Page 26
Playbooks---- hosts: webservers sudo: yes
tasks: - name: Ensure PHP is installed. apt: name=php5-common state=installed
Group
Module
Documentation
Arguments
Page 27
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
Back to the #Dramble
“Drupal 8 on a cluster of Raspberry Pis”
Page 33
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
Provisioning the ServersNo live demo: "Never rely on Conference WiFi"But we can talk about it later :-)
Page 35
Deploying Drupal 8
Demo
See: raspberry-pi-dramble on GitHub
Page 36
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 38
$ 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
____________________________________/ Drupal 8 is scalable, but not fast \\ ...yet. / ------------------------------------ \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||
Page 40
MORE DRAMBLE!Tons of benchmarksD8 performance and deployment discoverySee the Raspberry Pi Dramble Wiki
Page 41
MORE ANSIBLE!Docker integrationAWS, DigitalOcean, Rackspace, Softlayer, Linode, etc.NotificationsRolling updatesAnsible VaultDynamic inventoryetc...
Page 42
Resources•Ansible documentation•Ansible Vagrant examples•Ansible for DevOps•Raspberry Pi Dramble
Page 43
Feedback• https://joind.in/13825•Speaker name: @geerlingguy• #MidCamp• #Dramble
50% off Ansible or DevOps:http://bit.ly/midcamp-a4d