SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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'
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 

Kürzlich hochgeladen (20)

Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 

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