SlideShare a Scribd company logo
INTRODUCING ANSIBLE
What is it? What do we do with it? How?!
Tyler Turk
Uh… What are we talking about?
• Configuration Management Utility
• Automation Utility
• Easily extensible and pluggable framework
• Michael DeHaan, 2012 (developer of cobbler)
Please sir, may I have some
more?
• Written in Python
• Used for server config management
• Used for auditing of environment
Server-CM: Ansible 1.7.3
Masterchief: Ansible 0.9
THE DYNAMIC INVENTORY
What are inventories? What do
they contain?
• List of groups
• List of hosts in groups
• Potentially some
variables
What’s our inventory?
• Dynamic inventory interface based off server-
meta
• inventory/server_meta.py
• Groups generated by:
• server-meta-ranges
• Datacenter values
• ansible_groups property
Currently Extant Groups
• 64b-pod
• hapod
• 4g
• 8g-legacy
• development
• staging
• production
• protostaging
• vendor_group
• cloud
• dedicated
• clusters
Managing Disparate
Environments
• Primary API services production
• Dev API services development
• Corporate servers are handled with a flat file
Why is the inventory important?
• Groups are managed by dynamic inventory
• Skipping dynamic inventory means no groups
• No groups means incorrect variables set
• Systems will be configured incorrectly
Why do we need a custom
inventory?
• Multi-vendor strategy
• Custom data
requirements
• Assurance of
environment isolation
INVENTORY PATTERN
MATCHING
Access The Servers You Want!
• ‘pod-*’ # All pods
• ‘utility-*’ # All servers
with utility in the name
• ‘cluster-*:!dbmaster*’ #
All servers in each
cluster excluding
dbmaster
• ‘vendor:&pod-*’ # All
pods that exist in vendor
A simple example
Another example with explicit inclusion
IMPORTANCE OF
IDEMPOTENCE
What is idempotence?
f(x) = f(f(x)) = f(f(f(f(f(f(x))))))
• property of certain
operations in
mathematics and
computer science, that
can be applied multiple
times without changing
the result beyond the
initial application
•f(x) = f(f(x))
Okay… why do we care?
• Less accident prone
• We don’t break things
• Playbook is repeatable
• Helps to ensure same state, each time
Examples
• Idempotent Task:
lineinfile: dest=/etc/hosts line=“127.0.01 localhost” state=present
• Non-Idempotent Task:
shell: echo “127.0.01 localhost” >> /etc/hosts
AD-HOC USAGE
Ansible Runner
Welcome to Ad-Hoc
Usage
Useful Modules
• Apt
• Command
• Copy
• Fetch
• File
• Service
• Shell
• Stat
• Template
• User
• Zabbix Maintenance
Issues with Bash-isms
• Complex audits can
require mixed quotations
• Susceptible to shell
limitations
• Use python wrapper to
avoid bash-isms
Command Examples
ansible -i inventory/server_meta.py -m shell -a ‘ls /nas/local/ssl’ vendor
ansible -f 50 -m shell -a 'grep mysql.heartbeat
/etc/zabbix/zabbix_agentd.conf | wc -l' -i inventory/server_meta.py 'cluster*'
&>heart.out
ansible -f 50 -m copy -a "src=/root/ssl_sucks/cloudflare.conf
dest=/etc/wpengine/nginx/ssl.d/cloudflare.conf owner=root group=root
mode=0644" -i inventory/server_meta.py 'pod-*:hapod-*:web-*'
WHAT IS THIS PLAYBOOK
SORCERY?
What are playbooks?
• List of tasks
• Run against subset of
hosts
• Hopefully idempotent
What’s in a playbook?
• Conditional task execution
• Hosts
• Notifiable handlers
• Roles
• Variables
Example Playbook
Server Provisioning Playbooks
• Remote Playbook:
• Executed remotely
• Handles partitioning
• Initial Configuration
• Copies files out
• Platform Playbook:
• Executed locally
• Facts from remote
• Ensures packages
• Completes Config
Platform Deployment Playbook
• phased-deploy:
• git prefetch
• git checkout
• ensures consistent
phases
One-Off Playbooks
• build-server.yml
• Handles build server provisioning
• fire_and_forget_pull.yml
• Similar to nas2-prefetch.yml
• prepare-loadtest.yml
• Stages the droid install on a server
• remove_user.yml
• Removes user from our infrastructure
VARIABLE PRECEDENCE &
TROUBLESHOOTING
Introduction to Ansible Variables
• Regular variables:
Variables that are
explicitly defined either
via register or various
files / CLI options
• Magic variables:
Variables that are
defined automatically
Some Magic Variables
• hostvars
• ansible_distribution
• ansible_INTERFACE
• ansible_fqdn
• ansible_pkg_mgr
• group_names
• inventory_hostname
Variable Precedence
• Defined on the CLI (-e, --extra-vars)
• Connection variables
• “Most everything else”
• Inventory variables
• Discovered facts
• Role defaults
Wait… “most everything else…?”
• Included variables
• Host variables
• Group Variables
• Child group
• Parent group
• “All” variables, the super parent
• Define a variable as few times as possible
Using Lookup Plugins for
Variables
• with_items - Iterate through a list of items
• with_dict - Iterate through a dictionary
• with_fileglob - Iterate through a glob of files
• with_first_found - Iterate through files until one
is found
• Create your own!
JINJA2 TEMPLATING
FRAMEWORK
Introduction to Templating
group_vars/all:
is_vagrant: false
roles/common/templates/etc/hosts:
{% if is_vagrant %}
192.168.1.1 api.wpengine.com
{% endif %}
How to Loop in Templates
roles/common/templates/etc/hosts:
{% for ip in ansible_all_ipv4_addresses | sort %}
{{ ip }} {{ ansible_fqdn }}
{% endfor %}
roles/common/templates/etc/ansible_groups:
{% for name in group_names | sort %}
{{ name }}
{% endfor %}
Conditionals and Extensions
roles/apache/templates/var/www/index.jn2:
<html><head>
{% if maintenance_mode | default('', false) | bool %}
{% include "maintenance_header.html" %}
{% else %}
<title>Production - Ansible
Example</title></head><body>
<h3>Production mode FTW!</h3>
{% endif %}
</body></html>
Simple Demo Time!
ansible-playbook sample.yml
ansible-playbook sample.yml -e "maintenance_mode=false"
ansible-playbook sample.yml -e “maintenance_mode=true"
file:///Users/tylerturk/meetup/output/index.html
I WANT MORE OUT OF IT
Possible to Extend Upon
• Additional plugins can easily be dropped in
• Researching sample plugins goes a long way
• Several different plugin types currently
available
• Return results in JSON or hook however you
choose
Got questions? Ask!
Examples Available At:
https://github.com/tylerturk/ansible-examples-
jan28
Twitter: tylerjturk
Ad

More Related Content

What's hot (20)

Monitor-Driven Development Using Ansible
Monitor-Driven Development Using AnsibleMonitor-Driven Development Using Ansible
Monitor-Driven Development Using Ansible
Itamar Hassin
 
Docker Birtday #5
Docker Birtday #5Docker Birtday #5
Docker Birtday #5
Mehmet Ali Aydın
 
Jenkins and ansible reference
Jenkins and ansible referenceJenkins and ansible reference
Jenkins and ansible reference
laonap166
 
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
Jeff Geerling
 
Introduction to ansible galaxy
Introduction to ansible galaxyIntroduction to ansible galaxy
Introduction to ansible galaxy
Ivan Serdyuk
 
Testing Ansible with Jenkins and Docker
Testing Ansible with Jenkins and DockerTesting Ansible with Jenkins and Docker
Testing Ansible with Jenkins and Docker
Dennis Rowe
 
Ansible
AnsibleAnsible
Ansible
Rahul Bajaj
 
DevOps, A brief introduction to Vagrant & Ansible
DevOps, A brief introduction to Vagrant & AnsibleDevOps, A brief introduction to Vagrant & Ansible
DevOps, A brief introduction to Vagrant & Ansible
Arnaud LEMAIRE
 
Ansible 101
Ansible 101Ansible 101
Ansible 101
Gena Mykhailiuta
 
Ansible and AWS
Ansible and AWSAnsible and AWS
Ansible and AWS
Peter Sankauskas
 
Network automation (NetDevOps) with Ansible
Network automation (NetDevOps) with AnsibleNetwork automation (NetDevOps) with Ansible
Network automation (NetDevOps) with Ansible
Bangladesh Network Operators Group
 
Continuous Testing with Molecule, Ansible, and GitHub Actions
Continuous Testing with Molecule, Ansible, and GitHub ActionsContinuous Testing with Molecule, Ansible, and GitHub Actions
Continuous Testing with Molecule, Ansible, and GitHub Actions
Jeff Geerling
 
Debugging ansible modules
Debugging ansible modulesDebugging ansible modules
Debugging ansible modules
aleonhardt
 
Ansible + WordPress
Ansible + WordPressAnsible + WordPress
Ansible + WordPress
Alan Lok
 
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
Orestes Carracedo
 
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Simplilearn
 
Deploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleDeploying PHP Applications with Ansible
Deploying PHP Applications with Ansible
Orestes Carracedo
 
CI/CD Using Ansible and Jenkins for Infrastructure
CI/CD Using Ansible and Jenkins for InfrastructureCI/CD Using Ansible and Jenkins for Infrastructure
CI/CD Using Ansible and Jenkins for Infrastructure
Faisal Shaikh
 
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
 
Hands on ansible
Hands on ansibleHands on ansible
Hands on ansible
sumit23kumar
 
Monitor-Driven Development Using Ansible
Monitor-Driven Development Using AnsibleMonitor-Driven Development Using Ansible
Monitor-Driven Development Using Ansible
Itamar Hassin
 
Jenkins and ansible reference
Jenkins and ansible referenceJenkins and ansible reference
Jenkins and ansible reference
laonap166
 
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
Jeff Geerling
 
Introduction to ansible galaxy
Introduction to ansible galaxyIntroduction to ansible galaxy
Introduction to ansible galaxy
Ivan Serdyuk
 
Testing Ansible with Jenkins and Docker
Testing Ansible with Jenkins and DockerTesting Ansible with Jenkins and Docker
Testing Ansible with Jenkins and Docker
Dennis Rowe
 
DevOps, A brief introduction to Vagrant & Ansible
DevOps, A brief introduction to Vagrant & AnsibleDevOps, A brief introduction to Vagrant & Ansible
DevOps, A brief introduction to Vagrant & Ansible
Arnaud LEMAIRE
 
Continuous Testing with Molecule, Ansible, and GitHub Actions
Continuous Testing with Molecule, Ansible, and GitHub ActionsContinuous Testing with Molecule, Ansible, and GitHub Actions
Continuous Testing with Molecule, Ansible, and GitHub Actions
Jeff Geerling
 
Debugging ansible modules
Debugging ansible modulesDebugging ansible modules
Debugging ansible modules
aleonhardt
 
Ansible + WordPress
Ansible + WordPressAnsible + WordPress
Ansible + WordPress
Alan Lok
 
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
Orestes Carracedo
 
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Simplilearn
 
Deploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleDeploying PHP Applications with Ansible
Deploying PHP Applications with Ansible
Orestes Carracedo
 
CI/CD Using Ansible and Jenkins for Infrastructure
CI/CD Using Ansible and Jenkins for InfrastructureCI/CD Using Ansible and Jenkins for Infrastructure
CI/CD Using Ansible and Jenkins for Infrastructure
Faisal Shaikh
 
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
 

Viewers also liked (10)

Ansible, Idempotency, and Jenkins
Ansible, Idempotency, and JenkinsAnsible, Idempotency, and Jenkins
Ansible, Idempotency, and Jenkins
tylerturk
 
10/29 Austin Ansible MeetUp - AnsibleFest Talk & Extending Ansible
10/29 Austin Ansible MeetUp - AnsibleFest Talk & Extending Ansible10/29 Austin Ansible MeetUp - AnsibleFest Talk & Extending Ansible
10/29 Austin Ansible MeetUp - AnsibleFest Talk & Extending Ansible
tylerturk
 
Cooking 5 Star Infrastructure with Chef
Cooking 5 Star Infrastructure with ChefCooking 5 Star Infrastructure with Chef
Cooking 5 Star Infrastructure with Chef
G. Ryan Fawcett
 
Automated Application Management with SaltStack
Automated Application Management with SaltStackAutomated Application Management with SaltStack
Automated Application Management with SaltStack
inovex GmbH
 
Chef Cookbook Testing and Continuous Integration
Chef Cookbook Testing and Continuous IntegrationChef Cookbook Testing and Continuous Integration
Chef Cookbook Testing and Continuous Integration
Julian Dunn
 
Ansible - Introduction
Ansible - IntroductionAnsible - Introduction
Ansible - Introduction
Stephane Manciot
 
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In CodeIntroduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
Josh Padnick
 
Jenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated DeploymentJenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated Deployment
Dan Stine
 
Ansible Introduction
Ansible Introduction Ansible Introduction
Ansible Introduction
Robert Reiz
 
Journey to Cloud-Native: Where to start in your app modernization process
Journey to Cloud-Native: Where to start in your app modernization processJourney to Cloud-Native: Where to start in your app modernization process
Journey to Cloud-Native: Where to start in your app modernization process
VMware Tanzu
 
Ansible, Idempotency, and Jenkins
Ansible, Idempotency, and JenkinsAnsible, Idempotency, and Jenkins
Ansible, Idempotency, and Jenkins
tylerturk
 
10/29 Austin Ansible MeetUp - AnsibleFest Talk & Extending Ansible
10/29 Austin Ansible MeetUp - AnsibleFest Talk & Extending Ansible10/29 Austin Ansible MeetUp - AnsibleFest Talk & Extending Ansible
10/29 Austin Ansible MeetUp - AnsibleFest Talk & Extending Ansible
tylerturk
 
Cooking 5 Star Infrastructure with Chef
Cooking 5 Star Infrastructure with ChefCooking 5 Star Infrastructure with Chef
Cooking 5 Star Infrastructure with Chef
G. Ryan Fawcett
 
Automated Application Management with SaltStack
Automated Application Management with SaltStackAutomated Application Management with SaltStack
Automated Application Management with SaltStack
inovex GmbH
 
Chef Cookbook Testing and Continuous Integration
Chef Cookbook Testing and Continuous IntegrationChef Cookbook Testing and Continuous Integration
Chef Cookbook Testing and Continuous Integration
Julian Dunn
 
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In CodeIntroduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
Josh Padnick
 
Jenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated DeploymentJenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated Deployment
Dan Stine
 
Ansible Introduction
Ansible Introduction Ansible Introduction
Ansible Introduction
Robert Reiz
 
Journey to Cloud-Native: Where to start in your app modernization process
Journey to Cloud-Native: Where to start in your app modernization processJourney to Cloud-Native: Where to start in your app modernization process
Journey to Cloud-Native: Where to start in your app modernization process
VMware Tanzu
 
Ad

Similar to Introduction to Ansible - Jan 28 - Austin MeetUp (20)

Ansible for large scale deployment
Ansible for large scale deploymentAnsible for large scale deployment
Ansible for large scale deployment
Karthik .P.R
 
Ansible for large scale deployment
Ansible for large scale deploymentAnsible for large scale deployment
Ansible for large scale deployment
Remote MySQL DBA
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
Bas Meijer
 
20100425 Configuration Management With Puppet Lfnw
20100425 Configuration Management With Puppet Lfnw20100425 Configuration Management With Puppet Lfnw
20100425 Configuration Management With Puppet Lfnw
garrett honeycutt
 
Automated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAutomated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. Ansible
Alberto Molina Coballes
 
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
44CON
 
DrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilityDrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalability
cherryhillco
 
Ansible @ WebElement 2015
Ansible @ WebElement 2015Ansible @ WebElement 2015
Ansible @ WebElement 2015
Michal Maxian
 
CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011
Graham Weldon
 
Network Automation (NetDevOps) with Ansible
Network Automation (NetDevOps) with AnsibleNetwork Automation (NetDevOps) with Ansible
Network Automation (NetDevOps) with Ansible
APNIC
 
DevOps for database
DevOps for databaseDevOps for database
DevOps for database
Osama Mustafa
 
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
 
Drupal performance
Drupal performanceDrupal performance
Drupal performance
Piyuesh Kumar
 
Managing MySQL with Ansible
Managing MySQL with AnsibleManaging MySQL with Ansible
Managing MySQL with Ansible
Ben Mildren
 
Velocity 2011 Chef OpenStack Workshop
Velocity 2011 Chef OpenStack WorkshopVelocity 2011 Chef OpenStack Workshop
Velocity 2011 Chef OpenStack Workshop
Chef Software, Inc.
 
ServerTemplates - The Next Generation
ServerTemplates - The Next GenerationServerTemplates - The Next Generation
ServerTemplates - The Next Generation
RightScale
 
Yapc10 Cdt World Domination
Yapc10   Cdt World DominationYapc10   Cdt World Domination
Yapc10 Cdt World Domination
cPanel
 
So you want to liberate your data?
So you want to liberate your data?So you want to liberate your data?
So you want to liberate your data?
Mogens Heller Grabe
 
Top ten-list
Top ten-listTop ten-list
Top ten-list
Brian DeShong
 
Ansible top 10 - 2018
Ansible top 10 -  2018Ansible top 10 -  2018
Ansible top 10 - 2018
Viresh Doshi
 
Ansible for large scale deployment
Ansible for large scale deploymentAnsible for large scale deployment
Ansible for large scale deployment
Karthik .P.R
 
Ansible for large scale deployment
Ansible for large scale deploymentAnsible for large scale deployment
Ansible for large scale deployment
Remote MySQL DBA
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
Bas Meijer
 
20100425 Configuration Management With Puppet Lfnw
20100425 Configuration Management With Puppet Lfnw20100425 Configuration Management With Puppet Lfnw
20100425 Configuration Management With Puppet Lfnw
garrett honeycutt
 
Automated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAutomated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. Ansible
Alberto Molina Coballes
 
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
44CON
 
DrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilityDrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalability
cherryhillco
 
Ansible @ WebElement 2015
Ansible @ WebElement 2015Ansible @ WebElement 2015
Ansible @ WebElement 2015
Michal Maxian
 
CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011
Graham Weldon
 
Network Automation (NetDevOps) with Ansible
Network Automation (NetDevOps) with AnsibleNetwork Automation (NetDevOps) with Ansible
Network Automation (NetDevOps) with Ansible
APNIC
 
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
 
Managing MySQL with Ansible
Managing MySQL with AnsibleManaging MySQL with Ansible
Managing MySQL with Ansible
Ben Mildren
 
Velocity 2011 Chef OpenStack Workshop
Velocity 2011 Chef OpenStack WorkshopVelocity 2011 Chef OpenStack Workshop
Velocity 2011 Chef OpenStack Workshop
Chef Software, Inc.
 
ServerTemplates - The Next Generation
ServerTemplates - The Next GenerationServerTemplates - The Next Generation
ServerTemplates - The Next Generation
RightScale
 
Yapc10 Cdt World Domination
Yapc10   Cdt World DominationYapc10   Cdt World Domination
Yapc10 Cdt World Domination
cPanel
 
So you want to liberate your data?
So you want to liberate your data?So you want to liberate your data?
So you want to liberate your data?
Mogens Heller Grabe
 
Ansible top 10 - 2018
Ansible top 10 -  2018Ansible top 10 -  2018
Ansible top 10 - 2018
Viresh Doshi
 
Ad

Recently uploaded (20)

Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 

Introduction to Ansible - Jan 28 - Austin MeetUp

  • 1. INTRODUCING ANSIBLE What is it? What do we do with it? How?! Tyler Turk
  • 2. Uh… What are we talking about? • Configuration Management Utility • Automation Utility • Easily extensible and pluggable framework • Michael DeHaan, 2012 (developer of cobbler)
  • 3. Please sir, may I have some more? • Written in Python • Used for server config management • Used for auditing of environment
  • 6. What are inventories? What do they contain? • List of groups • List of hosts in groups • Potentially some variables
  • 7. What’s our inventory? • Dynamic inventory interface based off server- meta • inventory/server_meta.py • Groups generated by: • server-meta-ranges • Datacenter values • ansible_groups property
  • 8. Currently Extant Groups • 64b-pod • hapod • 4g • 8g-legacy • development • staging • production • protostaging • vendor_group • cloud • dedicated • clusters
  • 9. Managing Disparate Environments • Primary API services production • Dev API services development • Corporate servers are handled with a flat file
  • 10. Why is the inventory important? • Groups are managed by dynamic inventory • Skipping dynamic inventory means no groups • No groups means incorrect variables set • Systems will be configured incorrectly
  • 11. Why do we need a custom inventory? • Multi-vendor strategy • Custom data requirements • Assurance of environment isolation
  • 13. Access The Servers You Want! • ‘pod-*’ # All pods • ‘utility-*’ # All servers with utility in the name • ‘cluster-*:!dbmaster*’ # All servers in each cluster excluding dbmaster • ‘vendor:&pod-*’ # All pods that exist in vendor
  • 15. Another example with explicit inclusion
  • 17. What is idempotence? f(x) = f(f(x)) = f(f(f(f(f(f(x)))))) • property of certain operations in mathematics and computer science, that can be applied multiple times without changing the result beyond the initial application •f(x) = f(f(x))
  • 18. Okay… why do we care? • Less accident prone • We don’t break things • Playbook is repeatable • Helps to ensure same state, each time
  • 19. Examples • Idempotent Task: lineinfile: dest=/etc/hosts line=“127.0.01 localhost” state=present • Non-Idempotent Task: shell: echo “127.0.01 localhost” >> /etc/hosts
  • 22. Useful Modules • Apt • Command • Copy • Fetch • File • Service • Shell • Stat • Template • User • Zabbix Maintenance
  • 23. Issues with Bash-isms • Complex audits can require mixed quotations • Susceptible to shell limitations • Use python wrapper to avoid bash-isms
  • 24. Command Examples ansible -i inventory/server_meta.py -m shell -a ‘ls /nas/local/ssl’ vendor ansible -f 50 -m shell -a 'grep mysql.heartbeat /etc/zabbix/zabbix_agentd.conf | wc -l' -i inventory/server_meta.py 'cluster*' &>heart.out ansible -f 50 -m copy -a "src=/root/ssl_sucks/cloudflare.conf dest=/etc/wpengine/nginx/ssl.d/cloudflare.conf owner=root group=root mode=0644" -i inventory/server_meta.py 'pod-*:hapod-*:web-*'
  • 25. WHAT IS THIS PLAYBOOK SORCERY?
  • 26. What are playbooks? • List of tasks • Run against subset of hosts • Hopefully idempotent
  • 27. What’s in a playbook? • Conditional task execution • Hosts • Notifiable handlers • Roles • Variables
  • 29. Server Provisioning Playbooks • Remote Playbook: • Executed remotely • Handles partitioning • Initial Configuration • Copies files out • Platform Playbook: • Executed locally • Facts from remote • Ensures packages • Completes Config
  • 30. Platform Deployment Playbook • phased-deploy: • git prefetch • git checkout • ensures consistent phases
  • 31. One-Off Playbooks • build-server.yml • Handles build server provisioning • fire_and_forget_pull.yml • Similar to nas2-prefetch.yml • prepare-loadtest.yml • Stages the droid install on a server • remove_user.yml • Removes user from our infrastructure
  • 33. Introduction to Ansible Variables • Regular variables: Variables that are explicitly defined either via register or various files / CLI options • Magic variables: Variables that are defined automatically
  • 34. Some Magic Variables • hostvars • ansible_distribution • ansible_INTERFACE • ansible_fqdn • ansible_pkg_mgr • group_names • inventory_hostname
  • 35. Variable Precedence • Defined on the CLI (-e, --extra-vars) • Connection variables • “Most everything else” • Inventory variables • Discovered facts • Role defaults
  • 36. Wait… “most everything else…?” • Included variables • Host variables • Group Variables • Child group • Parent group • “All” variables, the super parent • Define a variable as few times as possible
  • 37. Using Lookup Plugins for Variables • with_items - Iterate through a list of items • with_dict - Iterate through a dictionary • with_fileglob - Iterate through a glob of files • with_first_found - Iterate through files until one is found • Create your own!
  • 39. Introduction to Templating group_vars/all: is_vagrant: false roles/common/templates/etc/hosts: {% if is_vagrant %} 192.168.1.1 api.wpengine.com {% endif %}
  • 40. How to Loop in Templates roles/common/templates/etc/hosts: {% for ip in ansible_all_ipv4_addresses | sort %} {{ ip }} {{ ansible_fqdn }} {% endfor %} roles/common/templates/etc/ansible_groups: {% for name in group_names | sort %} {{ name }} {% endfor %}
  • 41. Conditionals and Extensions roles/apache/templates/var/www/index.jn2: <html><head> {% if maintenance_mode | default('', false) | bool %} {% include "maintenance_header.html" %} {% else %} <title>Production - Ansible Example</title></head><body> <h3>Production mode FTW!</h3> {% endif %} </body></html>
  • 42. Simple Demo Time! ansible-playbook sample.yml ansible-playbook sample.yml -e "maintenance_mode=false" ansible-playbook sample.yml -e “maintenance_mode=true" file:///Users/tylerturk/meetup/output/index.html
  • 43. I WANT MORE OUT OF IT
  • 44. Possible to Extend Upon • Additional plugins can easily be dropped in • Researching sample plugins goes a long way • Several different plugin types currently available • Return results in JSON or hook however you choose
  • 45. Got questions? Ask! Examples Available At: https://github.com/tylerturk/ansible-examples- jan28 Twitter: tylerjturk