SlideShare a Scribd company logo
1 of 45
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

More Related Content

What's hot

Monitor-Driven Development Using Ansible
Monitor-Driven Development Using AnsibleMonitor-Driven Development Using Ansible
Monitor-Driven Development Using AnsibleItamar Hassin
 
Jenkins and ansible reference
Jenkins and ansible referenceJenkins and ansible reference
Jenkins and ansible referencelaonap166
 
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
 
Introduction to ansible galaxy
Introduction to ansible galaxyIntroduction to ansible galaxy
Introduction to ansible galaxyIvan Serdyuk
 
Testing Ansible with Jenkins and Docker
Testing Ansible with Jenkins and DockerTesting Ansible with Jenkins and Docker
Testing Ansible with Jenkins and DockerDennis 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 & AnsibleArnaud 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 ActionsJeff Geerling
 
Debugging ansible modules
Debugging ansible modulesDebugging ansible modules
Debugging ansible modulesaleonhardt
 
Ansible + WordPress
Ansible + WordPressAnsible + WordPress
Ansible + WordPressAlan 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 GroupOrestes 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 AnsibleOrestes Carracedo
 
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
 
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 InfrastructureFaisal 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
 

What's hot (20)

Monitor-Driven Development Using Ansible
Monitor-Driven Development Using AnsibleMonitor-Driven Development Using Ansible
Monitor-Driven Development Using Ansible
 
Docker Birtday #5
Docker Birtday #5Docker Birtday #5
Docker Birtday #5
 
Jenkins and ansible reference
Jenkins and ansible referenceJenkins and ansible reference
Jenkins and ansible reference
 
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
 
Introduction to ansible galaxy
Introduction to ansible galaxyIntroduction to ansible galaxy
Introduction to ansible galaxy
 
Testing Ansible with Jenkins and Docker
Testing Ansible with Jenkins and DockerTesting Ansible with Jenkins and Docker
Testing Ansible with Jenkins and Docker
 
Ansible
AnsibleAnsible
Ansible
 
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
 
Ansible 101
Ansible 101Ansible 101
Ansible 101
 
Ansible and AWS
Ansible and AWSAnsible and AWS
Ansible and AWS
 
Network automation (NetDevOps) with Ansible
Network automation (NetDevOps) with AnsibleNetwork automation (NetDevOps) with Ansible
Network automation (NetDevOps) with Ansible
 
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
 
Debugging ansible modules
Debugging ansible modulesDebugging ansible modules
Debugging ansible modules
 
Ansible + WordPress
Ansible + WordPressAnsible + WordPress
Ansible + WordPress
 
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 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 ...
 
Deploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleDeploying PHP Applications with Ansible
Deploying PHP Applications with Ansible
 
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
 
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
 
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, Idempotency, and Jenkins
Ansible, Idempotency, and JenkinsAnsible, Idempotency, and Jenkins
Ansible, Idempotency, and Jenkinstylerturk
 
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 Ansibletylerturk
 
Cooking 5 Star Infrastructure with Chef
Cooking 5 Star Infrastructure with ChefCooking 5 Star Infrastructure with Chef
Cooking 5 Star Infrastructure with ChefG. Ryan Fawcett
 
Automated Application Management with SaltStack
Automated Application Management with SaltStackAutomated Application Management with SaltStack
Automated Application Management with SaltStackinovex GmbH
 
Chef Cookbook Testing and Continuous Integration
Chef Cookbook Testing and Continuous IntegrationChef Cookbook Testing and Continuous Integration
Chef Cookbook Testing and Continuous IntegrationJulian 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 CodeJosh 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 DeploymentDan 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 processVMware Tanzu
 

Viewers also liked (10)

Ansible, Idempotency, and Jenkins
Ansible, Idempotency, and JenkinsAnsible, Idempotency, and Jenkins
Ansible, Idempotency, and Jenkins
 
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
 
Cooking 5 Star Infrastructure with Chef
Cooking 5 Star Infrastructure with ChefCooking 5 Star Infrastructure with Chef
Cooking 5 Star Infrastructure with Chef
 
Automated Application Management with SaltStack
Automated Application Management with SaltStackAutomated Application Management with SaltStack
Automated Application Management with SaltStack
 
Chef Cookbook Testing and Continuous Integration
Chef Cookbook Testing and Continuous IntegrationChef Cookbook Testing and Continuous Integration
Chef Cookbook Testing and Continuous Integration
 
Ansible - Introduction
Ansible - IntroductionAnsible - Introduction
Ansible - Introduction
 
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
 
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
 
Ansible Introduction
Ansible Introduction Ansible Introduction
Ansible Introduction
 
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
 

Similar to Introduction to Ansible - Jan 28 - Austin MeetUp

Ansible for large scale deployment
Ansible for large scale deploymentAnsible for large scale deployment
Ansible for large scale deploymentKarthik .P.R
 
Ansible for large scale deployment
Ansible for large scale deploymentAnsible for large scale deployment
Ansible for large scale deploymentRemote MySQL DBA
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practicesBas Meijer
 
20100425 Configuration Management With Puppet Lfnw
20100425 Configuration Management With Puppet Lfnw20100425 Configuration Management With Puppet Lfnw
20100425 Configuration Management With Puppet Lfnwgarrett honeycutt
 
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
 
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 scalabilitycherryhillco
 
Ansible @ WebElement 2015
Ansible @ WebElement 2015Ansible @ WebElement 2015
Ansible @ WebElement 2015Michal Maxian
 
CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011Graham Weldon
 
Network Automation (NetDevOps) with Ansible
Network Automation (NetDevOps) with AnsibleNetwork Automation (NetDevOps) with Ansible
Network Automation (NetDevOps) with AnsibleAPNIC
 
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 AnsibleBen Mildren
 
Velocity 2011 Chef OpenStack Workshop
Velocity 2011 Chef OpenStack WorkshopVelocity 2011 Chef OpenStack Workshop
Velocity 2011 Chef OpenStack WorkshopChef Software, Inc.
 
ServerTemplates - The Next Generation
ServerTemplates - The Next GenerationServerTemplates - The Next Generation
ServerTemplates - The Next GenerationRightScale
 
Yapc10 Cdt World Domination
Yapc10   Cdt World DominationYapc10   Cdt World Domination
Yapc10 Cdt World DominationcPanel
 
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 - 2018Viresh Doshi
 

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
 
Ansible for large scale deployment
Ansible for large scale deploymentAnsible for large scale deployment
Ansible for large scale deployment
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
 
20100425 Configuration Management With Puppet Lfnw
20100425 Configuration Management With Puppet Lfnw20100425 Configuration Management With Puppet Lfnw
20100425 Configuration Management With Puppet Lfnw
 
Automated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAutomated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. Ansible
 
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...
 
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
 
Ansible @ WebElement 2015
Ansible @ WebElement 2015Ansible @ WebElement 2015
Ansible @ WebElement 2015
 
CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011
 
Network Automation (NetDevOps) with Ansible
Network Automation (NetDevOps) with AnsibleNetwork Automation (NetDevOps) with Ansible
Network Automation (NetDevOps) with Ansible
 
DevOps for database
DevOps for databaseDevOps for database
DevOps for database
 
Go Faster with Ansible (PHP meetup)
Go Faster with Ansible (PHP meetup)Go Faster with Ansible (PHP meetup)
Go Faster with Ansible (PHP meetup)
 
Drupal performance
Drupal performanceDrupal performance
Drupal performance
 
Managing MySQL with Ansible
Managing MySQL with AnsibleManaging MySQL with Ansible
Managing MySQL with Ansible
 
Velocity 2011 Chef OpenStack Workshop
Velocity 2011 Chef OpenStack WorkshopVelocity 2011 Chef OpenStack Workshop
Velocity 2011 Chef OpenStack Workshop
 
ServerTemplates - The Next Generation
ServerTemplates - The Next GenerationServerTemplates - The Next Generation
ServerTemplates - The Next Generation
 
Yapc10 Cdt World Domination
Yapc10   Cdt World DominationYapc10   Cdt World Domination
Yapc10 Cdt World Domination
 
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?
 
Top ten-list
Top ten-listTop ten-list
Top ten-list
 
Ansible top 10 - 2018
Ansible top 10 -  2018Ansible top 10 -  2018
Ansible top 10 - 2018
 

Recently uploaded

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
🐬 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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 

Recently uploaded (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.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 🐘
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 

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