SlideShare une entreprise Scribd logo
1  sur  34
Go Faster with Ansible
AWS Bath Meetup
Richard Donkin
@rdonkin
$ whoami
• Richard Donkin
• DevOps engineer / contractor
• Ansible, Packer, Vagrant, Docker, Linux,
AWS, databases, …
• Experience of sys admin, DevOps,
backend dev, architecture, startups, …
@rdonkin
linkedin.com/in/rdonkin
www.tempohq.net
Goal: Faster Correct Setup
Servers
Apps
Developers
• Correct configuration
• No snowflake servers
• Dev, Test, Production
Infrastructure
As Code
Software processes and tools for
infrastructure configuration
What Ansible Does
Configuration Management
• Code that controls config
App Deployment
Orchestration
• Sequence operations on servers, APIs, etc.
Why Ansible?
• Agentless & serverless
• Simple
• Sequential
• Declarative tasks
• “Ensure nginx installed”
• Enables idempotence
• Easy to learn
• Scales to complex cloud orchestration
Quick Install
Mac:
brew install ansible
Debian/Ubuntu:
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get install -y ansible
RHEL/CentOS: use EPEL, then:
sudo yum –y install ansible
Any Linux (latest Ansible, requires Python):
sudo easy_install pip
sudo pip install ansible
Hello PHPMailer
Playbooks
Tasks
Idempotence
Key Concepts
Playbook = series of tasks
• Targets one server or thousands
• Servers defined by Inventory
Task = "ensure X is done" action
Play = set of tasks in playbook
Running a Playbook (1)
Running a Playbook (2)
Tasks will "skip" if state already OK
(Idempotence)
Writing a Playbook
Play – hosts to process, become == sudo
Tasks - descriptive name
- invoke module (apt) with parameters
Play
Task
The Secret Life of Tasks
Each task runs SSH commands that
• Upload a Module (e.g. apt)
• Run module with task's parameters
• Return JSON output
Inventory and Variables
Group your servers & assign parameters
[web]
10.0.1.51
10.0.1.52
[db]
10.0.1.61
[web:vars]
ansible_port=2222
$ ansible-playbook -i prod apache.yml --limit web
Ansible conditions based on groups and vars
(Typically) inventory file for dev, test, prod, ...
AWS Dynamic Inventory
Generated by ec2.py from AWS API
• EC2 instances, Route53, RDS, …
• Many params per instance, inc. one per tag
• Groups for regions, AZs, and Tags:
ansible tag_KEY_VALUE -m ping
Apache Playbook (1)
Vars = parameters for this playbook
Can be in separate include files
Or attach to hosts or host-groups in Inventory
- e.g. Listening IP address should be in inventory
Apache Playbook (2)
template task runs Jinja2 on local file and copies to
server
notify sends event to Handler
- Each Handler runs just once, at end of whole playbook
- Restart a service, notify Slack, ...
Apache Playbook (3)
service task uses systemctl to enable start on boot
- {{ apache_service }} instantiates var with Jinja2
Handler restarts apache at end if any task does a notify
Apache Playbook
Playbooks
Variables
Handlers
Modules
Over 840 modules "in the box"
- Git, yum, apt, compose, pip, gem, …
- Files: copy, template, edit, …
- Permissions, ownership, SELinux
- MySQL, PostgreSQL, MongoDB, ...
Targets:
- Linux, Windows, Mac, Docker, VMs
- AWS, Azure, GCP, network devices
Anything with an API or CLI
AWS Security Groups
Define security groups as vars in YAML
• Format defined by your playbook
• Each has list of rules (ingress and egress)
AWS Security Groups
Playbook applies all groups in a list
Roles
"Modularised playbooks"
- Split playbook into folder per type of content
- defaults folder for "parameter vars"
- vars folder for "role vars" – hard to override
- meta folder for role dependencies
Vars
Tasks
Handlers
Apache + PHP
playbook
Apache
role
PHP
role
Roles
Use Roles for everything!
Skinny playbooks + modular roles
Ideal playbook only calls roles, not tasks
Typical roles:
• create-vpc
• create-instances
• base, apache, php, redis
• deploy-app
"Wrapper roles" to invoke third party roles
Ansible Galaxy
Hub for 1000s of roles: galaxy.ansible.com
Discovery: Galaxy, GitHub, blogs, …
Assess quality carefully
Install the roles needed by project:
ansible-galaxy install –r requirements.yml
Pin the role to a version or Git commit
Testing Infra Code
Basic testing:
- Separate test playbook using Vagrant VM
- Travis CI popular for open source
- Smoke test at end of playbook:
Test frameworks:
- Test-Kitchen, ServerSpec, InSpec, testinfra
- Run whole series of tests - easier diagnosis
Drupal VM
Create a VM with one command: vagrant up
Ansible: 37 roles, 630 tasks, 7,200 lines of code
Resources
Book: Ansible for DevOps by Jeff Geerling – regular updates
Help: Stack Overflow, Ansible IRC + email lists
Roles:
• Geerlingguy roles – wide range – pragmatic & well maintained
• Ansistrano: Deploying PHP apps demo (atomic model)
Projects:
• Drupal-VM – http://drupalvm.com
• Trellis - https://roots.io/trellis/ - very complete WordPress setup
• Use example project – requires node, bower & gulp
Best practices: Ansible.com, blogs by Leucos and Nylas
Podcasts: Arrested DevOps – general DevOps and Infra as Code
Thank You
Richard Donkin
@rdonkin
linkedin.com/in/rdonkin
www.tempohq.net
Infrastructure as Code
Software processes for cloud resources
and server configs:
• Code review
• Version control
• Automated tests
• Automated push to servers
Rapid Growth in Ansible Activity
• Google Trends
• 5 years to Jan 2017
One Liners
Ad hoc command on single host, or group from inventory
Trellis: Modern WordPress
Near Twelve Factor WordPress
• Dev to Prod
• PHP 7.1, A+ SSL, HTTP/2, WP-CLI, …
• Example: rightsinfo.org
Related roots.io projects:
• Bedrock (WP boilerplate)
• Sage (starter theme)
• Some commercial add-ons
Example project (blog post):
• Install node, gulp, bower, Vagrant plugins
• vagrant up
• Some fixes required for Ansible 2.2
Advanced: Write a Module
Much more common to write a role
Required for major new features:
• New API
• New package tool
• New container format
Most modules written in Python
Any language is fine:
• PHP, C, Go, Perl, PowerShell, ...

Contenu connexe

Tendances

How Ansible Makes Automation Easy
How Ansible Makes Automation EasyHow Ansible Makes Automation Easy
How Ansible Makes Automation EasyPeter Sankauskas
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationSuresh Kumar
 
Jenkins and ansible reference
Jenkins and ansible referenceJenkins and ansible reference
Jenkins and ansible referencelaonap166
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansibleKhizer Naeem
 
Ansible Automation to Rule Them All
Ansible Automation to Rule Them AllAnsible Automation to Rule Them All
Ansible Automation to Rule Them AllTim Fairweather
 
Deploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleDeploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleOrestes Carracedo
 
A quick intro to Ansible
A quick intro to AnsibleA quick intro to Ansible
A quick intro to AnsibleDan Vaida
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practicesBas Meijer
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationKumar Y
 
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Ansible 2.0 - How to use Ansible to automate your applications in AWS.Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Ansible 2.0 - How to use Ansible to automate your applications in AWS.Idan Tohami
 
Managing Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with AnsibleManaging Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with Ansiblefmaccioni
 
Infrastructure = Code
Infrastructure = CodeInfrastructure = Code
Infrastructure = CodeGeorg Sorst
 
Getting Started with Ansible
Getting Started with AnsibleGetting Started with Ansible
Getting Started with AnsibleAhmed AbouZaid
 
Getting started with Ansible
Getting started with AnsibleGetting started with Ansible
Getting started with AnsibleIvan Serdyuk
 
Ansible Oxford - Cows & Containers
Ansible Oxford - Cows & ContainersAnsible Oxford - Cows & Containers
Ansible Oxford - Cows & Containersjonatanblue
 
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
 

Tendances (20)

How Ansible Makes Automation Easy
How Ansible Makes Automation EasyHow Ansible Makes Automation Easy
How Ansible Makes Automation Easy
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Ansible Case Studies
Ansible Case StudiesAnsible Case Studies
Ansible Case Studies
 
Jenkins and ansible reference
Jenkins and ansible referenceJenkins and ansible reference
Jenkins and ansible reference
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansible
 
Ansible Automation to Rule Them All
Ansible Automation to Rule Them AllAnsible Automation to Rule Them All
Ansible Automation to Rule Them All
 
Deploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleDeploying PHP Applications with Ansible
Deploying PHP Applications with Ansible
 
A quick intro to Ansible
A quick intro to AnsibleA quick intro to Ansible
A quick intro to Ansible
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
 
Ansible
AnsibleAnsible
Ansible
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Ansible - A 'crowd' introduction
Ansible - A 'crowd' introductionAnsible - A 'crowd' introduction
Ansible - A 'crowd' introduction
 
Ansible and AWS
Ansible and AWSAnsible and AWS
Ansible and AWS
 
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Ansible 2.0 - How to use Ansible to automate your applications in AWS.Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
 
Managing Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with AnsibleManaging Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with Ansible
 
Infrastructure = Code
Infrastructure = CodeInfrastructure = Code
Infrastructure = Code
 
Getting Started with Ansible
Getting Started with AnsibleGetting Started with Ansible
Getting Started with Ansible
 
Getting started with Ansible
Getting started with AnsibleGetting started with Ansible
Getting started with Ansible
 
Ansible Oxford - Cows & Containers
Ansible Oxford - Cows & ContainersAnsible Oxford - Cows & Containers
Ansible Oxford - Cows & Containers
 
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!
 

En vedette

Automation with Ansible and Containers
Automation with Ansible and ContainersAutomation with Ansible and Containers
Automation with Ansible and ContainersRodolfo Carvalho
 
Ansible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetupAnsible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetupGreg DeKoenigsberg
 
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpecTest-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpecMartin Etmajer
 
Infrastructure Deployment with Docker & Ansible
Infrastructure Deployment with Docker & AnsibleInfrastructure Deployment with Docker & Ansible
Infrastructure Deployment with Docker & AnsibleRobert Reiz
 
Automate with Ansible basic (2/e, English)
Automate with Ansible basic (2/e, English)Automate with Ansible basic (2/e, English)
Automate with Ansible basic (2/e, English)Chu-Siang Lai
 
Capítol 1 música amagada
Capítol 1 música amagadaCapítol 1 música amagada
Capítol 1 música amagadaJoanprofe
 
「民進党ゆるキャラ総選挙」人気を予測しました
「民進党ゆるキャラ総選挙」人気を予測しました「民進党ゆるキャラ総選挙」人気を予測しました
「民進党ゆるキャラ総選挙」人気を予測しましたToshihisa Tanaka
 
Microservices. The good, the bad and the ugly.
Microservices. The good, the bad and the ugly.Microservices. The good, the bad and the ugly.
Microservices. The good, the bad and the ugly.Sander Hoogendoorn
 
Update version of the SMBE/SESBE Lecture on ENCODE & junk DNA (Graur, Decembe...
Update version of the SMBE/SESBE Lecture on ENCODE & junk DNA (Graur, Decembe...Update version of the SMBE/SESBE Lecture on ENCODE & junk DNA (Graur, Decembe...
Update version of the SMBE/SESBE Lecture on ENCODE & junk DNA (Graur, Decembe...Dan Graur
 
Introduction to customer success by Guy Nirpaz @ Totango
Introduction to customer success  by Guy Nirpaz @ TotangoIntroduction to customer success  by Guy Nirpaz @ Totango
Introduction to customer success by Guy Nirpaz @ TotangoCEO Quest
 
インクルーシブ教育システムの構築に向けたスクールワイドな支援モデルの可能性
インクルーシブ教育システムの構築に向けたスクールワイドな支援モデルの可能性インクルーシブ教育システムの構築に向けたスクールワイドな支援モデルの可能性
インクルーシブ教育システムの構築に向けたスクールワイドな支援モデルの可能性Akina Noguchi
 
Fc - 5 fortes motivos meninas aprenderem a programar já
Fc - 5 fortes motivos meninas aprenderem a programar jáFc - 5 fortes motivos meninas aprenderem a programar já
Fc - 5 fortes motivos meninas aprenderem a programar jáJayme Nigri
 
仕事で使うF#
仕事で使うF#仕事で使うF#
仕事で使うF#bleis tift
 
ปรัชญากับวิถีชีวิต
ปรัชญากับวิถีชีวิตปรัชญากับวิถีชีวิต
ปรัชญากับวิถีชีวิตPadvee Academy
 
How *NOT* to firmware
How *NOT* to firmwareHow *NOT* to firmware
How *NOT* to firmwareAmit Serper
 
1ST YEAR Infographics about team sport
 1ST YEAR Infographics about team sport 1ST YEAR Infographics about team sport
1ST YEAR Infographics about team sportCiclos Formativos
 

En vedette (20)

Automation with Ansible and Containers
Automation with Ansible and ContainersAutomation with Ansible and Containers
Automation with Ansible and Containers
 
Ansible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetupAnsible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetup
 
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpecTest-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
 
Infrastructure Deployment with Docker & Ansible
Infrastructure Deployment with Docker & AnsibleInfrastructure Deployment with Docker & Ansible
Infrastructure Deployment with Docker & Ansible
 
Automate with Ansible basic (2/e, English)
Automate with Ansible basic (2/e, English)Automate with Ansible basic (2/e, English)
Automate with Ansible basic (2/e, English)
 
Capítol 1 música amagada
Capítol 1 música amagadaCapítol 1 música amagada
Capítol 1 música amagada
 
「民進党ゆるキャラ総選挙」人気を予測しました
「民進党ゆるキャラ総選挙」人気を予測しました「民進党ゆるキャラ総選挙」人気を予測しました
「民進党ゆるキャラ総選挙」人気を予測しました
 
Microservices. The good, the bad and the ugly.
Microservices. The good, the bad and the ugly.Microservices. The good, the bad and the ugly.
Microservices. The good, the bad and the ugly.
 
Sadigh Gallery Spring Savings Events 2017
Sadigh Gallery Spring Savings Events 2017Sadigh Gallery Spring Savings Events 2017
Sadigh Gallery Spring Savings Events 2017
 
Update version of the SMBE/SESBE Lecture on ENCODE & junk DNA (Graur, Decembe...
Update version of the SMBE/SESBE Lecture on ENCODE & junk DNA (Graur, Decembe...Update version of the SMBE/SESBE Lecture on ENCODE & junk DNA (Graur, Decembe...
Update version of the SMBE/SESBE Lecture on ENCODE & junk DNA (Graur, Decembe...
 
Presentacion estrella rural
Presentacion estrella ruralPresentacion estrella rural
Presentacion estrella rural
 
Introduction to customer success by Guy Nirpaz @ Totango
Introduction to customer success  by Guy Nirpaz @ TotangoIntroduction to customer success  by Guy Nirpaz @ Totango
Introduction to customer success by Guy Nirpaz @ Totango
 
インクルーシブ教育システムの構築に向けたスクールワイドな支援モデルの可能性
インクルーシブ教育システムの構築に向けたスクールワイドな支援モデルの可能性インクルーシブ教育システムの構築に向けたスクールワイドな支援モデルの可能性
インクルーシブ教育システムの構築に向けたスクールワイドな支援モデルの可能性
 
White paper on french companies in india
White paper on french companies in indiaWhite paper on french companies in india
White paper on french companies in india
 
Fc - 5 fortes motivos meninas aprenderem a programar já
Fc - 5 fortes motivos meninas aprenderem a programar jáFc - 5 fortes motivos meninas aprenderem a programar já
Fc - 5 fortes motivos meninas aprenderem a programar já
 
仕事で使うF#
仕事で使うF#仕事で使うF#
仕事で使うF#
 
Pieredze daudzdzīvokļu dzīvojamo māju siltināšanā
Pieredze daudzdzīvokļu dzīvojamo māju siltināšanāPieredze daudzdzīvokļu dzīvojamo māju siltināšanā
Pieredze daudzdzīvokļu dzīvojamo māju siltināšanā
 
ปรัชญากับวิถีชีวิต
ปรัชญากับวิถีชีวิตปรัชญากับวิถีชีวิต
ปรัชญากับวิถีชีวิต
 
How *NOT* to firmware
How *NOT* to firmwareHow *NOT* to firmware
How *NOT* to firmware
 
1ST YEAR Infographics about team sport
 1ST YEAR Infographics about team sport 1ST YEAR Infographics about team sport
1ST YEAR Infographics about team sport
 

Similaire à Go Faster with Ansible (AWS meetup)

RTP NPUG: Ansible Intro and Integration with ACI
RTP NPUG: Ansible Intro and Integration with ACIRTP NPUG: Ansible Intro and Integration with ACI
RTP NPUG: Ansible Intro and Integration with ACIJoel W. King
 
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
 
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Ansible 2.0 - How to use Ansible to automate your applications in AWS.Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Ansible 2.0 - How to use Ansible to automate your applications in AWS.Idan Tohami
 
Ansible on aws - Pop-up Loft Tel Aviv
Ansible on aws - Pop-up Loft Tel AvivAnsible on aws - Pop-up Loft Tel Aviv
Ansible on aws - Pop-up Loft Tel AvivAmazon Web Services
 
Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdfNigussMehari4
 
Ansible Devops North East - slides
Ansible Devops North East - slides Ansible Devops North East - slides
Ansible Devops North East - slides InfinityPP
 
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.
 
Automated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAutomated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAlberto Molina Coballes
 
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
 
Docker - Demo on PHP Application deployment
Docker - Demo on PHP Application deployment Docker - Demo on PHP Application deployment
Docker - Demo on PHP Application deployment Arun prasath
 
Ransack, an Application Built on Ansible's API for Rackspace -- AnsibleFest N...
Ransack, an Application Built on Ansible's API for Rackspace -- AnsibleFest N...Ransack, an Application Built on Ansible's API for Rackspace -- AnsibleFest N...
Ransack, an Application Built on Ansible's API for Rackspace -- AnsibleFest N...Paul Durivage
 
Bhushan m dev_ops_engr_31june
Bhushan m dev_ops_engr_31juneBhushan m dev_ops_engr_31june
Bhushan m dev_ops_engr_31juneBhushan Mahajan
 
Bhushan m dev_ops_engr_aws
Bhushan m dev_ops_engr_awsBhushan m dev_ops_engr_aws
Bhushan m dev_ops_engr_awsBhushan Mahajan
 
Containerization is more than the new Virtualization: enabling separation of ...
Containerization is more than the new Virtualization: enabling separation of ...Containerization is more than the new Virtualization: enabling separation of ...
Containerization is more than the new Virtualization: enabling separation of ...Jérôme Petazzoni
 
Best Practices for Running Kafka on Docker Containers
Best Practices for Running Kafka on Docker ContainersBest Practices for Running Kafka on Docker Containers
Best Practices for Running Kafka on Docker ContainersBlueData, Inc.
 
Net Devops Overview
Net Devops OverviewNet Devops Overview
Net Devops OverviewJoel W. King
 
Containerization Is More than the New Virtualization
Containerization Is More than the New VirtualizationContainerization Is More than the New Virtualization
Containerization Is More than the New VirtualizationC4Media
 

Similaire à Go Faster with Ansible (AWS meetup) (20)

RTP NPUG: Ansible Intro and Integration with ACI
RTP NPUG: Ansible Intro and Integration with ACIRTP NPUG: Ansible Intro and Integration with ACI
RTP NPUG: Ansible Intro and Integration with ACI
 
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
 
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Ansible 2.0 - How to use Ansible to automate your applications in AWS.Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
 
Ansible on aws - Pop-up Loft Tel Aviv
Ansible on aws - Pop-up Loft Tel AvivAnsible on aws - Pop-up Loft Tel Aviv
Ansible on aws - Pop-up Loft Tel Aviv
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
 
Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdf
 
Ansible Devops North East - slides
Ansible Devops North East - slides Ansible Devops North East - slides
Ansible Devops North East - slides
 
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
 
Automated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAutomated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. Ansible
 
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
 
Devops in Networking
Devops in NetworkingDevops in Networking
Devops in Networking
 
Docker - Demo on PHP Application deployment
Docker - Demo on PHP Application deployment Docker - Demo on PHP Application deployment
Docker - Demo on PHP Application deployment
 
Ransack, an Application Built on Ansible's API for Rackspace -- AnsibleFest N...
Ransack, an Application Built on Ansible's API for Rackspace -- AnsibleFest N...Ransack, an Application Built on Ansible's API for Rackspace -- AnsibleFest N...
Ransack, an Application Built on Ansible's API for Rackspace -- AnsibleFest N...
 
Bhushan m dev_ops_engr_31june
Bhushan m dev_ops_engr_31juneBhushan m dev_ops_engr_31june
Bhushan m dev_ops_engr_31june
 
Bhushan m dev_ops_engr_aws
Bhushan m dev_ops_engr_awsBhushan m dev_ops_engr_aws
Bhushan m dev_ops_engr_aws
 
Containerization is more than the new Virtualization: enabling separation of ...
Containerization is more than the new Virtualization: enabling separation of ...Containerization is more than the new Virtualization: enabling separation of ...
Containerization is more than the new Virtualization: enabling separation of ...
 
Best Practices for Running Kafka on Docker Containers
Best Practices for Running Kafka on Docker ContainersBest Practices for Running Kafka on Docker Containers
Best Practices for Running Kafka on Docker Containers
 
Net Devops Overview
Net Devops OverviewNet Devops Overview
Net Devops Overview
 
Containerization Is More than the New Virtualization
Containerization Is More than the New VirtualizationContainerization Is More than the New Virtualization
Containerization Is More than the New Virtualization
 

Dernier

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 

Dernier (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

Go Faster with Ansible (AWS meetup)

  • 1. Go Faster with Ansible AWS Bath Meetup Richard Donkin @rdonkin
  • 2. $ whoami • Richard Donkin • DevOps engineer / contractor • Ansible, Packer, Vagrant, Docker, Linux, AWS, databases, … • Experience of sys admin, DevOps, backend dev, architecture, startups, … @rdonkin linkedin.com/in/rdonkin www.tempohq.net
  • 3. Goal: Faster Correct Setup Servers Apps Developers • Correct configuration • No snowflake servers • Dev, Test, Production
  • 4. Infrastructure As Code Software processes and tools for infrastructure configuration
  • 5. What Ansible Does Configuration Management • Code that controls config App Deployment Orchestration • Sequence operations on servers, APIs, etc.
  • 6. Why Ansible? • Agentless & serverless • Simple • Sequential • Declarative tasks • “Ensure nginx installed” • Enables idempotence • Easy to learn • Scales to complex cloud orchestration
  • 7. Quick Install Mac: brew install ansible Debian/Ubuntu: sudo apt-add-repository ppa:ansible/ansible sudo apt-get install -y ansible RHEL/CentOS: use EPEL, then: sudo yum –y install ansible Any Linux (latest Ansible, requires Python): sudo easy_install pip sudo pip install ansible
  • 9. Key Concepts Playbook = series of tasks • Targets one server or thousands • Servers defined by Inventory Task = "ensure X is done" action Play = set of tasks in playbook
  • 11. Running a Playbook (2) Tasks will "skip" if state already OK (Idempotence)
  • 12. Writing a Playbook Play – hosts to process, become == sudo Tasks - descriptive name - invoke module (apt) with parameters Play Task
  • 13. The Secret Life of Tasks Each task runs SSH commands that • Upload a Module (e.g. apt) • Run module with task's parameters • Return JSON output
  • 14. Inventory and Variables Group your servers & assign parameters [web] 10.0.1.51 10.0.1.52 [db] 10.0.1.61 [web:vars] ansible_port=2222 $ ansible-playbook -i prod apache.yml --limit web Ansible conditions based on groups and vars (Typically) inventory file for dev, test, prod, ...
  • 15. AWS Dynamic Inventory Generated by ec2.py from AWS API • EC2 instances, Route53, RDS, … • Many params per instance, inc. one per tag • Groups for regions, AZs, and Tags: ansible tag_KEY_VALUE -m ping
  • 16. Apache Playbook (1) Vars = parameters for this playbook Can be in separate include files Or attach to hosts or host-groups in Inventory - e.g. Listening IP address should be in inventory
  • 17. Apache Playbook (2) template task runs Jinja2 on local file and copies to server notify sends event to Handler - Each Handler runs just once, at end of whole playbook - Restart a service, notify Slack, ...
  • 18. Apache Playbook (3) service task uses systemctl to enable start on boot - {{ apache_service }} instantiates var with Jinja2 Handler restarts apache at end if any task does a notify
  • 20. Modules Over 840 modules "in the box" - Git, yum, apt, compose, pip, gem, … - Files: copy, template, edit, … - Permissions, ownership, SELinux - MySQL, PostgreSQL, MongoDB, ... Targets: - Linux, Windows, Mac, Docker, VMs - AWS, Azure, GCP, network devices Anything with an API or CLI
  • 21. AWS Security Groups Define security groups as vars in YAML • Format defined by your playbook • Each has list of rules (ingress and egress)
  • 22. AWS Security Groups Playbook applies all groups in a list
  • 23. Roles "Modularised playbooks" - Split playbook into folder per type of content - defaults folder for "parameter vars" - vars folder for "role vars" – hard to override - meta folder for role dependencies Vars Tasks Handlers Apache + PHP playbook Apache role PHP role
  • 24. Roles Use Roles for everything! Skinny playbooks + modular roles Ideal playbook only calls roles, not tasks Typical roles: • create-vpc • create-instances • base, apache, php, redis • deploy-app "Wrapper roles" to invoke third party roles
  • 25. Ansible Galaxy Hub for 1000s of roles: galaxy.ansible.com Discovery: Galaxy, GitHub, blogs, … Assess quality carefully Install the roles needed by project: ansible-galaxy install –r requirements.yml Pin the role to a version or Git commit
  • 26. Testing Infra Code Basic testing: - Separate test playbook using Vagrant VM - Travis CI popular for open source - Smoke test at end of playbook: Test frameworks: - Test-Kitchen, ServerSpec, InSpec, testinfra - Run whole series of tests - easier diagnosis
  • 27. Drupal VM Create a VM with one command: vagrant up Ansible: 37 roles, 630 tasks, 7,200 lines of code
  • 28. Resources Book: Ansible for DevOps by Jeff Geerling – regular updates Help: Stack Overflow, Ansible IRC + email lists Roles: • Geerlingguy roles – wide range – pragmatic & well maintained • Ansistrano: Deploying PHP apps demo (atomic model) Projects: • Drupal-VM – http://drupalvm.com • Trellis - https://roots.io/trellis/ - very complete WordPress setup • Use example project – requires node, bower & gulp Best practices: Ansible.com, blogs by Leucos and Nylas Podcasts: Arrested DevOps – general DevOps and Infra as Code
  • 30. Infrastructure as Code Software processes for cloud resources and server configs: • Code review • Version control • Automated tests • Automated push to servers
  • 31. Rapid Growth in Ansible Activity • Google Trends • 5 years to Jan 2017
  • 32. One Liners Ad hoc command on single host, or group from inventory
  • 33. Trellis: Modern WordPress Near Twelve Factor WordPress • Dev to Prod • PHP 7.1, A+ SSL, HTTP/2, WP-CLI, … • Example: rightsinfo.org Related roots.io projects: • Bedrock (WP boilerplate) • Sage (starter theme) • Some commercial add-ons Example project (blog post): • Install node, gulp, bower, Vagrant plugins • vagrant up • Some fixes required for Ansible 2.2
  • 34. Advanced: Write a Module Much more common to write a role Required for major new features: • New API • New package tool • New container format Most modules written in Python Any language is fine: • PHP, C, Go, Perl, PowerShell, ...

Notes de l'éditeur

  1. Photo credit: https://www.flickr.com/photos/automobileitalia/16675249764/
  2. Go Faster without creating new problems... "Faster" really means more iterations per day / week Servers created much faster, without manual work Apps deployed automatically, without mistakes or omissions Deveopers on-boarded very fast, without manual installs This means: Configuration must be correct, even when moving faster Avoid snowflake servers (every one is different in detailed config) scale across dev, test, staging, production
  3. Capistrano style "atomic symlink" deployment involves having a single symbolic link called "current" pointing to the release that's live. Deployment means pushing the new files into a new release directory, then atomically switching the link. See Ansistrano, which enables this Capistrano model using Ansible, enabling customisation for more complex models as required. There is also f500.project-deploy, which is less powerful e.g. no before/after hooks. Rocketeer is a PHP tool that does the same thing. Fabric is a Python tool that can do anything on servers, often used for simpler deployments – requires Python coding and is lower level than Ansistrano Although Ansible can do both CM and App deployment, you normally want quite separate server configuration management and app deployment scripts (Playbooks). - "CM is a process, deployment is an event"
  4. – agentless - only requires SSH & Python on server simple but powerful sequential model for tasks Declarative tasks easy to learn compared to Puppet/Chef/Salt - explicit ordering visible in code, unlike Puppet/Salt easy orchestration e.g. easy to remove servers from LB during upgrade, and rollback if X% fail: Remove server from load balancer Deploy app & reboot Restore to load balancer
  5. Upgrades are easy with the "Any Linux" method – just do "pip install --upgrade ansible" For Windows, use a Linux VM on VirtualBox – Ubuntu is probably easiest option. Or use Windows 10's "bash shell" (Linux subsystem for Windows), which is a reasonably complete Ubuntu userland on the Windows kernel.
  6. Setup task = get server info (OS, hardware) – built in, can disable with "gather_facts: no" at top of play
  7. Parameters – single line or indented YAML The single line format (e.g. update_cache=yes) is unique to Ansible, and not part of YAML The indented format (e.g. "apt:") is YAML YAML is equivalent to JSON, using indentation. Use the "-" syntax to create a list – each new item is a list entry (equivalent to a PHP array with integer index values) Use the "foo: bar" syntax to create a key-value pair within a dictionary (equivalent to a PHP array with string index values)
  8. Originally known as "hosts file" – term still used in Ansible error messages Default is /etc/ansible/hosts but that's not very useful in most cases where you have different projects, environments, etc. Getting the right inventory structure, and locating variables in right place, is a key decision in Ansible projects. Generally, try to have variables in as few places as possible, e.g.: role defaults, role vars, host group vars, and use wrapper roles (mentioned later) to encapsulate vars you need for roles. Some people prefer a "group + environment" naming scheme, or moving each inventory file to a separate directory.
  9. This is very powerful – for example if you have a tag servertype with value prod_webserver, you can use the Ansible host group tag_servertype_prod_webserver to configure only those servers, without writing any extra code.
  10. - This is a simplified extract from a real-world Ansible project, the Drupal-VM role "geerlingguy.apache", combining various elements into a single playbook.
  11. Can target network switches and routers that don't have Python If you use Windows, you normally need a Linux VM to actually run Ansible, targetting Windows servers via WinRM and modules normally written in PowerShell, or leveraging PowerShell DSC (a basic config engine for Windows). Ansible is used to manage some large Windows deployments including over 1,000 servers on Azure at Jet.com.
  12. Roles are more reusable if they focus on a single logical service, or a related set of config – e.g. Apache, PHP and PHP-FPM are more re-usable if written as separate roles. Files are searched for within the current role, avoiding complex relative paths in many cases
  13. Look for steady development, several contributors, many commits, discussion on GitHub Always pin the role – this avoids surprises when your project changes "Vendoring" the role can help i.e. install into a "vendor/roles" folder in your project – be sure to adjust your ansible.cfg's role_path Galaxy is not that easy to browse/search, and most of the action is on GitHub I usually install directly from GitHub using Ansible Galaxy as a discovery and installation tool only.
  14. Goal: Test-driven infrastructure ServerSpec and InSpec provide English-like BDD testing using a DSL based on Ruby Testinfra provides simple unit tests using Python Just as with app testing, infra testing frameworks are generally more powerful than using Ansible to test itself – e.g. you can easily run just a few tests RoleSpec specifically tests Ansible roles – the others focus more on the outputs of the roles
  15. Fully open source
  16. Server config problem? Code a fix
  17. - can't really track "Chef" searches as Google Trends doesn't offer a software classification of term.
  18. Try these as well: ansible web -m setup -a 'filter=ansible_all_ip* ansible devbox -m setup -a 'filter=ansible_mem*'
  19. Requires node, bower and gulp and some Vagrant plugins Should work with Ansible 2.0.2.0 as specified in the docs (run "pip install --upgrade ansible==2.0.2.0" as long as you're already using the "pip install ansible" method to install Ansible). Some fixes needed for Ansible 2.2 (mailhog and logrotate roles, php-fpm pool from wordpress-setup role, and composer role) Trellis clone gives you trellis tree (ansible), then Bedrock clone gives you WP site tree, and Sage clone populates WP theme inside that Includes Nginx "micro caching" for 5 sec to Reddit-proof your site