SlideShare a Scribd company logo
1 of 25
Download to read offline
ANSIBLE + WORDPRESS
ALAN LOK
BECAUSE YOU NEED THEM
GOALS
• Simple* and repeatable installs
• Automate your tasks
*Simple ≠ Easy
Sorry, everything takes effort
MASTER
(WORDPRESS)

BUILDER?
ARE YOU A
CC, Source: Flickr/VGB.Studios
A TOOL FOR ALL OF US
ANSIBLE
• Automate machine
provisioning and
deployments
• Agentless
• Configuration
management
• Idempotent
(TELL ME THE MAGIC)
HOW DOES ANSIBLE FIT IN?
• An orchestration machine with a usable shell prompt (*NIX)
• Server(s) accessible by SSH to orchestrate changes
SSH
http://docs.ansible.com/ansible/intro_installation.html
HOW TO INSTALL ANSIBLE
• CentOS/RH/Amazon Linux:

sudo yum install ansible
• Debian:

sudo apt-get install ansible
• OS X:

sudo easy_install pip; sudo pip install ansible
• Windows: sorry :(
BASICS
ANSIBLE
THE THING YOU DO
TASK AND HANDLER
• A task is the most granular
“thing” you do. For example:
• Copy a file
• Start a process
• Create a file using Jinja2 syntax
• Tasks are linear, whereas handlers
are invoked by task completion
(similar to WordPress hooks)
• Tasks can loop, and may contain
conditional evaluation
A CONTAINER FOR TASKS AND HANDLERS
ROLES
• Roles are sets of tasks and
handlers that Ansible
executes
• Think shell script, but
better organized and
easier to read
• Roles can have default
variables, and be
overridden by a play
HOW ANSIBLE STITCHES IT TOGETHER
PLAYBOOK
• A playbook is a
collection of plays
• A play is a
collection of roles
• One can assign plays
to a host or host
group
http://docs.ansible.com/ansible/playbooks.html
CONFIGURATION MANAGEMENT’S BEST FRIEND
VARIABLES
• Variables can be specified at 3
levels
• Global (config / env /
command line)
• Play
• Host
• Don’t hard code configuration,
leverage variables and set
defaults for overriding
{x}http://docs.ansible.com/ansible/playbooks_variables.html
DEFINING WHO WE ARE
HOSTS
• A play can target a host or a
group of hosts
• Inventory may be static or
dynamic (eg. AWS)
• Specific host-related
information to access server
• User must have sudo
privileges to perform
system tasks
TOGETHER
PUTTING IT ALL
CONFIGURE A HOST
1.Make a SSH key pair

ssh-keygen -t ecdsa -f deploy
2.Copy your key file to the host (deploy.pub) and

append the file contents to ~/.ssh/authorized_keys
3.Ensure the host user has sudo access (or else “become” parameter
won’t work)
4.Ensure the python module python-httplib2 is installed
5.Disable selinux
http://docs.ansible.com/ansible/intro_inventory.html
CREATE YOUR HOST FILE
[wordpress]
172.16.12.146 ansible_user=alan ansible_ssh_private_key_file=deploy
Host Group
IP or FQDN Ansible options
YOU DON’T HAVE TO WRITE EVERY ROLE
DOWNLOAD SOME ROLES
ansible-galaxy install
sbaerlocher.wp-cli
geerlingguy.php
geerlingguy.apache
geerlingguy.mysql

geerlingguy.php-mysql

geerlingguy.firewall
BECAUSE NOT ALL ROLES WORK OUT OF THE BOX
MODIFING GALAXY ROLES
• Let’s check out 2 roles I modified

https://github.com/alanlok/ansible-role-wordpress.git

https://github.com/alanlok/ansible-role-wordpress-apache.git
• Modified from ansible-galaxy author darthwade’s roles
• Made more variables available for customization
• Made roles RedHat/CentOS/Amazon Linux friendly
• You can write your own roles too!
FILES IN YOUR STRUCTURE
CREATING YOUR OWN PLAYBOOK
•group_vars
•wordpress
•config
•roles
•ansible-role-wordpress
•ansible-role-wordpress-apache
•hosts
•wordpress-simple.yml
YAML file containing your

host group’s variables
Your custom roles

in the roles directory
Which hosts should Ansible act on
Your playbook
SECRET SAUCE TO MAKE IT UNIQUE
THE GROUP VARIABLES
---
apache_user: "apache"
apache_group: "apache"
wp_version: 4.5
wp_site_name: 'site1'
wp_install_dir: '/var/www/html/{{ wp_site_name }}'
wp_db_name: '{{ wp_site_name }}'
wp_db_user: '{{ wp_site_name }}_user'
wp_db_password: 'password'
wp_db_host: 'localhost'
wp_apache_hostname: '{{ wp_site_name }}.vm'
Yup, how else can I give a demo!
This is not pretty.

See “vault” for more details.
DONEC QUIS NUNC
THE PLAYBOOK
- hosts: wordpress
become: yes
roles:
- geerlingguy.apache
- geerlingguy.php
- geerlingguy.mysql
- geerlingguy.firewall
- geerlingguy.php-mysql
- ansible-role-wordpress
- ansible-role-wordpress-apache
- sbaerlocher.wp-cli
LET’S RUN THIS…
ansible-playbook -i hosts
wordpress-simple.yml
SORTA?
IT’S DEPLOYED…
THE REAL VOODOO
LET’S RUN SOME AD-HOC COMMANDS
• Configure WordPress for the first time

ansible -i hosts wordpress --become -a "sudo -u apache wp core
install --url=site1.vm --title="Yet another demo" --admin_user
=alan --admin_password=alan --admin_email="alan@wlx.ca" --path
=/var/www/html/site1"
• Update WordPress

ansible -i hosts wordpress --become -a "sudo -u apache wp core update
—path=/var/www/html/site1"
• Update server:

ansible -i hosts wordpress --become -a "yum update -y"
• Reboot server:

ansible -i hosts wordpress --become -a "reboot"
”
“
— The LEGO® Movie
EVERYTHING IS AWESOME!!!
THANKS
@alan_lok

More Related Content

What's hot

Local Dev on Virtual Machines - Vagrant, VirtualBox and Ansible
Local Dev on Virtual Machines - Vagrant, VirtualBox and AnsibleLocal Dev on Virtual Machines - Vagrant, VirtualBox and Ansible
Local Dev on Virtual Machines - Vagrant, VirtualBox and AnsibleJeff Geerling
 
Network Automation with Ansible
Network Automation with AnsibleNetwork Automation with Ansible
Network Automation with AnsibleAnas
 
Testing Ansible with Jenkins and Docker
Testing Ansible with Jenkins and DockerTesting Ansible with Jenkins and Docker
Testing Ansible with Jenkins and DockerDennis Rowe
 
Ansible Automation to Rule Them All
Ansible Automation to Rule Them AllAnsible Automation to Rule Them All
Ansible Automation to Rule Them AllTim Fairweather
 
Ansible 101 - Presentation at Ansible STL Meetup
Ansible 101 - Presentation at Ansible STL MeetupAnsible 101 - Presentation at Ansible STL Meetup
Ansible 101 - Presentation at Ansible STL MeetupJeff Geerling
 
Ansible Intro - June 2015 / Ansible Barcelona User Group
Ansible Intro - June 2015 / Ansible Barcelona User GroupAnsible Intro - June 2015 / Ansible Barcelona User Group
Ansible Intro - June 2015 / Ansible Barcelona User GroupOrestes Carracedo
 
Hands On Introduction To Ansible Configuration Management With Ansible Comple...
Hands On Introduction To Ansible Configuration Management With Ansible Comple...Hands On Introduction To Ansible Configuration Management With Ansible Comple...
Hands On Introduction To Ansible Configuration Management With Ansible Comple...SlideTeam
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansibleKhizer Naeem
 
DevOps - Infrastructure as Code by Andre Marcelo-Tanner
DevOps - Infrastructure as Code by Andre Marcelo-TannerDevOps - Infrastructure as Code by Andre Marcelo-Tanner
DevOps - Infrastructure as Code by Andre Marcelo-TannerDEVCON
 
Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015Chef
 
DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!Jeff Geerling
 
Go Faster with Ansible (PHP meetup)
Go Faster with Ansible (PHP meetup)Go Faster with Ansible (PHP meetup)
Go Faster with Ansible (PHP meetup)Richard Donkin
 
DevOps in a Regulated World - aka 'Ansible, AWS, and Jenkins'
DevOps in a Regulated World - aka 'Ansible, AWS, and Jenkins'DevOps in a Regulated World - aka 'Ansible, AWS, and Jenkins'
DevOps in a Regulated World - aka 'Ansible, AWS, and Jenkins'rmcleay
 

What's hot (20)

Local Dev on Virtual Machines - Vagrant, VirtualBox and Ansible
Local Dev on Virtual Machines - Vagrant, VirtualBox and AnsibleLocal Dev on Virtual Machines - Vagrant, VirtualBox and Ansible
Local Dev on Virtual Machines - Vagrant, VirtualBox and Ansible
 
Ansible Case Studies
Ansible Case StudiesAnsible Case Studies
Ansible Case Studies
 
Network Automation with Ansible
Network Automation with AnsibleNetwork Automation with Ansible
Network Automation with Ansible
 
Testing Ansible with Jenkins and Docker
Testing Ansible with Jenkins and DockerTesting Ansible with Jenkins and Docker
Testing Ansible with Jenkins and Docker
 
Ansible and AWS
Ansible and AWSAnsible and AWS
Ansible and AWS
 
Ansible Automation to Rule Them All
Ansible Automation to Rule Them AllAnsible Automation to Rule Them All
Ansible Automation to Rule Them All
 
Ansible 101 - Presentation at Ansible STL Meetup
Ansible 101 - Presentation at Ansible STL MeetupAnsible 101 - Presentation at Ansible STL Meetup
Ansible 101 - Presentation at Ansible STL Meetup
 
Ansible Intro - June 2015 / Ansible Barcelona User Group
Ansible Intro - June 2015 / Ansible Barcelona User GroupAnsible Intro - June 2015 / Ansible Barcelona User Group
Ansible Intro - June 2015 / Ansible Barcelona User Group
 
ansible why ?
ansible why ?ansible why ?
ansible why ?
 
Hands On Introduction To Ansible Configuration Management With Ansible Comple...
Hands On Introduction To Ansible Configuration Management With Ansible Comple...Hands On Introduction To Ansible Configuration Management With Ansible Comple...
Hands On Introduction To Ansible Configuration Management With Ansible Comple...
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansible
 
DevOps - Infrastructure as Code by Andre Marcelo-Tanner
DevOps - Infrastructure as Code by Andre Marcelo-TannerDevOps - Infrastructure as Code by Andre Marcelo-Tanner
DevOps - Infrastructure as Code by Andre Marcelo-Tanner
 
Ansible - A 'crowd' introduction
Ansible - A 'crowd' introductionAnsible - A 'crowd' introduction
Ansible - A 'crowd' introduction
 
Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015
 
Ansible 101
Ansible 101Ansible 101
Ansible 101
 
Introducing Ansible
Introducing AnsibleIntroducing Ansible
Introducing Ansible
 
DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!
 
Go Faster with Ansible (PHP meetup)
Go Faster with Ansible (PHP meetup)Go Faster with Ansible (PHP meetup)
Go Faster with Ansible (PHP meetup)
 
Ansible
AnsibleAnsible
Ansible
 
DevOps in a Regulated World - aka 'Ansible, AWS, and Jenkins'
DevOps in a Regulated World - aka 'Ansible, AWS, and Jenkins'DevOps in a Regulated World - aka 'Ansible, AWS, and Jenkins'
DevOps in a Regulated World - aka 'Ansible, AWS, and Jenkins'
 

Viewers also liked

Ansible 101, Gennadiy Mykhailiuta
Ansible 101, Gennadiy MykhailiutaAnsible 101, Gennadiy Mykhailiuta
Ansible 101, Gennadiy MykhailiutaTetiana Saputo
 
Verifying your Ansible Roles using Docker, Test Kitchen and Serverspec
Verifying your Ansible Roles using Docker, Test Kitchen and ServerspecVerifying your Ansible Roles using Docker, Test Kitchen and Serverspec
Verifying your Ansible Roles using Docker, Test Kitchen and ServerspecEdmund Dipple
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansibleOmid Vahdaty
 
Automated Deployments with Ansible
Automated Deployments with AnsibleAutomated Deployments with Ansible
Automated Deployments with AnsibleMartin Etmajer
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practicesBas Meijer
 
Ansible tips & tricks
Ansible tips & tricksAnsible tips & tricks
Ansible tips & tricksbcoca
 
Ansible Introduction
Ansible Introduction Ansible Introduction
Ansible Introduction Robert Reiz
 

Viewers also liked (12)

Ansible
AnsibleAnsible
Ansible
 
Ansible 202 - sysarmy
Ansible 202 - sysarmyAnsible 202 - sysarmy
Ansible 202 - sysarmy
 
Ansible 101, Gennadiy Mykhailiuta
Ansible 101, Gennadiy MykhailiutaAnsible 101, Gennadiy Mykhailiuta
Ansible 101, Gennadiy Mykhailiuta
 
Verifying your Ansible Roles using Docker, Test Kitchen and Serverspec
Verifying your Ansible Roles using Docker, Test Kitchen and ServerspecVerifying your Ansible Roles using Docker, Test Kitchen and Serverspec
Verifying your Ansible Roles using Docker, Test Kitchen and Serverspec
 
Ansible 202
Ansible 202Ansible 202
Ansible 202
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
Ansible
AnsibleAnsible
Ansible
 
Ansible - Introduction
Ansible - IntroductionAnsible - Introduction
Ansible - Introduction
 
Automated Deployments with Ansible
Automated Deployments with AnsibleAutomated Deployments with Ansible
Automated Deployments with Ansible
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
 
Ansible tips & tricks
Ansible tips & tricksAnsible tips & tricks
Ansible tips & tricks
 
Ansible Introduction
Ansible Introduction Ansible Introduction
Ansible Introduction
 

Similar to Ansible + WordPress

Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Alex S
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with AnsibleRayed Alrashed
 
Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdfNigussMehari4
 
Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)Jun Hong Kim
 
Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Alex S
 
A tour of Ansible
A tour of AnsibleA tour of Ansible
A tour of AnsibleDevOps Ltd.
 
Webinar: Automate IBM Connections Installations and more
Webinar: Automate IBM Connections Installations and moreWebinar: Automate IBM Connections Installations and more
Webinar: Automate IBM Connections Installations and morepanagenda
 
Hosting a Rails App
Hosting a Rails AppHosting a Rails App
Hosting a Rails AppJosh Schramm
 
Ansible at work
Ansible at workAnsible at work
Ansible at workBas Meijer
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleStein Inge Morisbak
 
WordPress CLI in-depth
WordPress CLI in-depthWordPress CLI in-depth
WordPress CLI in-depthSanjay Willie
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014biicode
 
02 Hadoop deployment and configuration
02 Hadoop deployment and configuration02 Hadoop deployment and configuration
02 Hadoop deployment and configurationSubhas Kumar Ghosh
 
Ansible new paradigms for orchestration
Ansible new paradigms for orchestrationAnsible new paradigms for orchestration
Ansible new paradigms for orchestrationPaolo Tonin
 
Fun with containers: Use Ansible to build Docker images
Fun with containers: Use Ansible to build Docker imagesFun with containers: Use Ansible to build Docker images
Fun with containers: Use Ansible to build Docker imagesabadger1999
 
Continuous Integration & Development with Gitlab
Continuous Integration & Development with GitlabContinuous Integration & Development with Gitlab
Continuous Integration & Development with GitlabAyush Sharma
 
Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)
Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)
Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)Codemotion
 
#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to AnsibleCédric Delgehier
 

Similar to Ansible + WordPress (20)

Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
 
Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdf
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
 
Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)
 
Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015
 
A tour of Ansible
A tour of AnsibleA tour of Ansible
A tour of Ansible
 
Webinar: Automate IBM Connections Installations and more
Webinar: Automate IBM Connections Installations and moreWebinar: Automate IBM Connections Installations and more
Webinar: Automate IBM Connections Installations and more
 
Hosting a Rails App
Hosting a Rails AppHosting a Rails App
Hosting a Rails App
 
Ansible at work
Ansible at workAnsible at work
Ansible at work
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with Ansible
 
Automating with Ansible
Automating with AnsibleAutomating with Ansible
Automating with Ansible
 
WordPress CLI in-depth
WordPress CLI in-depthWordPress CLI in-depth
WordPress CLI in-depth
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
 
02 Hadoop deployment and configuration
02 Hadoop deployment and configuration02 Hadoop deployment and configuration
02 Hadoop deployment and configuration
 
Ansible new paradigms for orchestration
Ansible new paradigms for orchestrationAnsible new paradigms for orchestration
Ansible new paradigms for orchestration
 
Fun with containers: Use Ansible to build Docker images
Fun with containers: Use Ansible to build Docker imagesFun with containers: Use Ansible to build Docker images
Fun with containers: Use Ansible to build Docker images
 
Continuous Integration & Development with Gitlab
Continuous Integration & Development with GitlabContinuous Integration & Development with Gitlab
Continuous Integration & Development with Gitlab
 
Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)
Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)
Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)
 
#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible
 

Recently uploaded

eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024VictoriaMetrics
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Anthony Dahanne
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 

Recently uploaded (20)

eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 

Ansible + WordPress

  • 2. BECAUSE YOU NEED THEM GOALS • Simple* and repeatable installs • Automate your tasks *Simple ≠ Easy Sorry, everything takes effort
  • 3. MASTER (WORDPRESS)
 BUILDER? ARE YOU A CC, Source: Flickr/VGB.Studios
  • 4. A TOOL FOR ALL OF US ANSIBLE • Automate machine provisioning and deployments • Agentless • Configuration management • Idempotent
  • 5. (TELL ME THE MAGIC) HOW DOES ANSIBLE FIT IN? • An orchestration machine with a usable shell prompt (*NIX) • Server(s) accessible by SSH to orchestrate changes SSH
  • 6. http://docs.ansible.com/ansible/intro_installation.html HOW TO INSTALL ANSIBLE • CentOS/RH/Amazon Linux:
 sudo yum install ansible • Debian:
 sudo apt-get install ansible • OS X:
 sudo easy_install pip; sudo pip install ansible • Windows: sorry :(
  • 8. THE THING YOU DO TASK AND HANDLER • A task is the most granular “thing” you do. For example: • Copy a file • Start a process • Create a file using Jinja2 syntax • Tasks are linear, whereas handlers are invoked by task completion (similar to WordPress hooks) • Tasks can loop, and may contain conditional evaluation
  • 9. A CONTAINER FOR TASKS AND HANDLERS ROLES • Roles are sets of tasks and handlers that Ansible executes • Think shell script, but better organized and easier to read • Roles can have default variables, and be overridden by a play
  • 10. HOW ANSIBLE STITCHES IT TOGETHER PLAYBOOK • A playbook is a collection of plays • A play is a collection of roles • One can assign plays to a host or host group http://docs.ansible.com/ansible/playbooks.html
  • 11. CONFIGURATION MANAGEMENT’S BEST FRIEND VARIABLES • Variables can be specified at 3 levels • Global (config / env / command line) • Play • Host • Don’t hard code configuration, leverage variables and set defaults for overriding {x}http://docs.ansible.com/ansible/playbooks_variables.html
  • 12. DEFINING WHO WE ARE HOSTS • A play can target a host or a group of hosts • Inventory may be static or dynamic (eg. AWS) • Specific host-related information to access server • User must have sudo privileges to perform system tasks
  • 14. CONFIGURE A HOST 1.Make a SSH key pair
 ssh-keygen -t ecdsa -f deploy 2.Copy your key file to the host (deploy.pub) and
 append the file contents to ~/.ssh/authorized_keys 3.Ensure the host user has sudo access (or else “become” parameter won’t work) 4.Ensure the python module python-httplib2 is installed 5.Disable selinux
  • 15. http://docs.ansible.com/ansible/intro_inventory.html CREATE YOUR HOST FILE [wordpress] 172.16.12.146 ansible_user=alan ansible_ssh_private_key_file=deploy Host Group IP or FQDN Ansible options
  • 16. YOU DON’T HAVE TO WRITE EVERY ROLE DOWNLOAD SOME ROLES ansible-galaxy install sbaerlocher.wp-cli geerlingguy.php geerlingguy.apache geerlingguy.mysql
 geerlingguy.php-mysql
 geerlingguy.firewall
  • 17. BECAUSE NOT ALL ROLES WORK OUT OF THE BOX MODIFING GALAXY ROLES • Let’s check out 2 roles I modified
 https://github.com/alanlok/ansible-role-wordpress.git
 https://github.com/alanlok/ansible-role-wordpress-apache.git • Modified from ansible-galaxy author darthwade’s roles • Made more variables available for customization • Made roles RedHat/CentOS/Amazon Linux friendly • You can write your own roles too!
  • 18. FILES IN YOUR STRUCTURE CREATING YOUR OWN PLAYBOOK •group_vars •wordpress •config •roles •ansible-role-wordpress •ansible-role-wordpress-apache •hosts •wordpress-simple.yml YAML file containing your
 host group’s variables Your custom roles
 in the roles directory Which hosts should Ansible act on Your playbook
  • 19. SECRET SAUCE TO MAKE IT UNIQUE THE GROUP VARIABLES --- apache_user: "apache" apache_group: "apache" wp_version: 4.5 wp_site_name: 'site1' wp_install_dir: '/var/www/html/{{ wp_site_name }}' wp_db_name: '{{ wp_site_name }}' wp_db_user: '{{ wp_site_name }}_user' wp_db_password: 'password' wp_db_host: 'localhost' wp_apache_hostname: '{{ wp_site_name }}.vm' Yup, how else can I give a demo! This is not pretty.
 See “vault” for more details.
  • 20. DONEC QUIS NUNC THE PLAYBOOK - hosts: wordpress become: yes roles: - geerlingguy.apache - geerlingguy.php - geerlingguy.mysql - geerlingguy.firewall - geerlingguy.php-mysql - ansible-role-wordpress - ansible-role-wordpress-apache - sbaerlocher.wp-cli
  • 21. LET’S RUN THIS… ansible-playbook -i hosts wordpress-simple.yml
  • 23. THE REAL VOODOO LET’S RUN SOME AD-HOC COMMANDS • Configure WordPress for the first time
 ansible -i hosts wordpress --become -a "sudo -u apache wp core install --url=site1.vm --title="Yet another demo" --admin_user =alan --admin_password=alan --admin_email="alan@wlx.ca" --path =/var/www/html/site1" • Update WordPress
 ansible -i hosts wordpress --become -a "sudo -u apache wp core update —path=/var/www/html/site1" • Update server:
 ansible -i hosts wordpress --become -a "yum update -y" • Reboot server:
 ansible -i hosts wordpress --become -a "reboot"
  • 24. ” “ — The LEGO® Movie EVERYTHING IS AWESOME!!!