ansible + drupal: a fortuitous devops match

43
Ansible + Drupal A fortuitous DevOps Match #MidCamp 2015 JeGeerling Technical Architect, Acquia ________________________________________ / "Automation shouldn't be your day job" \ \ #ansible #pycon2014 / ---------------------------------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||

Upload: jeff-geerling

Post on 16-Jul-2015

2.606 views

Category:

Software


2 download

TRANSCRIPT

Ansible + DrupalA fortuitous DevOps Match

#MidCamp 2015 Jeff GeerlingTechnical Architect, Acquia

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

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

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

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

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

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

Over 270 modules built-in

Over 3,000 roles on Ansible Galaxy

Extensible, modular APIs (JSON, language-agnostic)

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

Ansible 1011. Inventory: Describe your infrastructure

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

3. Playbooks: "Infrastructure as code"

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

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

Please help me avoid the Xenon Death Flash

The #Dramble

CPU 24 cores / 5.4 GHz

RAM 6 GB

Storage 96 GB microSD

Network 10/100 over Gigabit network

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

INI syntax

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

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

INI syntax

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

Group

Servers in group

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

$ ansible webservers -m ping

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

$ ansible webservers -m ping

Group

Module

Ad-Hoc commandsHave fun with RGB LEDs!

$ ansible webservers -a "rgb red" -s

Ad-Hoc commandsHave fun with RGB LEDs!

$ ansible webservers -a "rgb red" -s

Group

'Use sudo'

Command

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

Ad-Hoc commands

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

Ad-Hoc commands

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

Module Arguments

PlaybooksAd-Hoc commands don't solve the snowflake problem

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

Unique, by Pen Waggener

Playbooks---- hosts: webservers sudo: yes

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

Playbooks---- hosts: webservers sudo: yes

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

Group

Module

Documentation

Arguments

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)

Back to the #Dramble

“Drupal 8 on a cluster of Raspberry Pis”

Architecture

Architecture

Architecture

Architecture

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!

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

Deploying Drupal 8

Demo

See: raspberry-pi-dramble on GitHub

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"

$ 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

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

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

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

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

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

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