SlideShare a Scribd company logo
Provisioning, Config, Execution, (more) Fun
Steve Pereira
18 years in IT
Startups and Enterprise
Love learning about,
teaching and talking about:
• DevOps
• CI/CD
• Automation
• Scale
WHO AM I?
ANSIBLE FEATURES
• Automation for local and remote system provisioning
• Automation for local and remote applications deployment
• No agents to install on remote systems
• Using existing SSHd on remote systems and native SSH on host
• Parallel by default - scale to 6000 targets with single master
• Language that approaches plain english
ANSIBLE CONVENTIONS
Playbooks - contain required tasks to configure systems and deploy
Tasks - individual actions to perform on remote or local machines
Roles - modular, single-purpose configurations for systems
Inventory - files containing address information of target machines
Handlers - actions triggered by tasks
Templates - customizable files destined for managed machines
MINIMUM VIABLE ANSIBLE
$ ansible all -i 'localhost,' -c local -m ping
localhost | success >> {
"changed": false,
"ping": "pong"
}
WHAT ELSE?
• ansible webservers -m setup
• ansible lb -m copy -a "src=hosts dest=/tmp/hosts”
• ansible webservers -m yum -a "name=curl state=installed”
• ansible webservers -m service -a "name=nginx
state=restarted”
• ansible-doc -l
PLAYBOOKS---
- hosts: webservers
vars:
http_port: 80
max_clients: 200
remote_user: root
tasks:
- name: ensure apache is at the latest version
yum: pkg=httpd state=latest
- name: write the apache config file
template: src=/https/www.slideshare.net/srv/httpd.j2 dest=/etc/httpd.conf
notify:
- restart apache
- name: ensure apache is running (and enable it at boot)
service: name=httpd state=started enabled=yes
handlers:
- name: restart apache
service: name=httpd state=restarted
example_playbook.yml
PLAYBOOKS---
- hosts: webservers
vars:
http_port: 80
max_clients: 200
remote_user: root
tasks:
- name: ensure apache is at the latest version
yum: pkg=httpd state=latest
- name: write the apache config file
template: src=/https/www.slideshare.net/srv/httpd.j2 dest=/etc/httpd.conf
notify:
- restart apache
- name: ensure apache is running (and enable it at boot)
service: name=httpd state=started enabled=yes
handlers:
- name: restart apache
service: name=httpd state=restarted
example_playbook.yml
PLAYBOOKS---
- hosts: webservers
vars:
http_port: 80
max_clients: 200
remote_user: root
tasks:
- name: ensure apache is at the latest version
yum: pkg=httpd state=latest
- name: write the apache config file
template: src=/https/www.slideshare.net/srv/httpd.j2 dest=/etc/httpd.conf
notify:
- restart apache
- name: ensure apache is running (and enable it at boot)
service: name=httpd state=started enabled=yes
handlers:
- name: restart apache
service: name=httpd state=restarted
example_playbook.yml
PLAYBOOKS---
- hosts: webservers
vars:
http_port: 80
max_clients: 200
remote_user: root
tasks:
- name: ensure apache is at the latest version
yum: pkg=httpd state=latest
- name: write the apache config file
template: src=/https/www.slideshare.net/srv/httpd.j2 dest=/etc/httpd.conf
notify:
- restart apache
- name: ensure apache is running (and enable it at boot)
service: name=httpd state=started enabled=yes
handlers:
- name: restart apache
service: name=httpd state=restarted
example_playbook.yml
PLAYBOOKS---
- hosts: webservers
vars:
http_port: 80
max_clients: 200
remote_user: root
tasks:
- name: ensure apache is at the latest version
yum: pkg=httpd state=latest
- name: write the apache config file
template: src=/https/www.slideshare.net/srv/httpd.j2 dest=/etc/httpd.conf
notify:
- restart apache
- name: ensure apache is running (and enable it at boot)
service: name=httpd state=started enabled=yes
handlers:
- name: restart apache
service: name=httpd state=restarted
example_playbook.yml
PLAYBOOKS---
- hosts: webservers
vars:
http_port: 80
max_clients: 200
remote_user: root
tasks:
- name: ensure apache is at the latest version
yum: pkg=httpd state=latest
- name: write the apache config file
template: src=/https/www.slideshare.net/srv/httpd.j2 dest=/etc/httpd.conf
notify:
- restart apache
- name: ensure apache is running (and enable it at boot)
service: name=httpd state=started enabled=yes
handlers:
- name: restart apache
service: name=httpd state=restarted
example_playbook.yml
PLAYBOOKS---
- hosts: webservers
vars:
http_port: 80
max_clients: 200
remote_user: root
tasks:
- name: ensure apache is at the latest version
yum: pkg=httpd state=latest
- name: write the apache config file
template: src=/https/www.slideshare.net/srv/httpd.j2 dest=/etc/httpd.conf
notify:
- restart apache
- name: ensure apache is running (and enable it at boot)
service: name=httpd state=started enabled=yes
handlers:
- name: restart apache
service: name=httpd state=restarted
example_playbook.yml
ROLES
my_role/
README.md (readme)
defaults/ (default values)
meta/ (role metadata)
files/ (binaries)
templates/ (file templates)
handlers/ (operation handlers)
tasks/ (playbook files)
vars/ (custom variables)
• Easily packaged and shared
• Download community roles
• Mix and match
INVENTORY
• Define how ansible will interact with remote hosts
• Define logical groups of managed nodes
• One file for each environment
• Default location : /etc/ansible/hosts
• INI format, variable overrides
sample_inventory.ini [loadbalancers]
10.20.30.41
10.20.30.42
[webservers]
10.20.30.51 hostname=artemis
10.20.30.52 hostname=apollo
TEMPLATES
• Use Jinja2 templating and variables to customize
• Defaults available when variables not provided (dev default with prod override)
etc_logrotate.d.j2 {{ logfile }} {
rotate {{ 7 | rotate_max }}
{{ daily | frequency }}
compress
missingok
notifempty
}
IT CAN GET FANCY
tasks:
- name: install packages in a users virtualenv
  shell: su - c {{ item[0] }} '(. ./bin/activate && pip install {{ item[1] }})'
  with_nested:
      - [ 'jim', 'joe', 'jack' ]
      - [ package1==1.1,
          package2==1.2,
          package3==1.3 ]
There are several types of loops:
Hashes, Fileglobs, Sequence, Subelements, First match, Command results, Random and
more
but there’s a builtin pip module, anyways.
CONDITIONALS
tasks:
- command: /bin/false
register: result
ignore_errors:True
- command: /bin/something
when: result|failed
- command: /bin/something_else
when: result|success
- command: /bin/still/something_else
when: result|skipped
The result of a play can depend on
the value of a variable, fact
(something learned about the
remote system), or previous task
result.
MORE CONDITIONALS!
tasks:
- shell: echo "I've got '{{ foo }}'"
when: foo is defined
- fail: msg="This play requires 'bar'"
when: bar is not defined
- command: echo {{ item }}
with_items: [ 0, 2, 4, 6, 8, 10 ]
when: item > 5
If a required variable has not been
set, you can skip or fail using
Jinja2’s defined test. For example:
SIMPLE, POWERFUL BUILTINS
• 261 built-in modules
• Many cloud providers, packages and tools are integrated
• Easily add your own in any language
examples: • ec2 - Create, terminate, start/stop an instance
• docker - Manage docker containers
• hipchat Send a message to hipchat
• s3 - manage objects in S3
• twilio - Sends a text message to a phone
• win_service - Manages Windows services
• zfs - Manage zfs
SMOOTH OPERATION
•Get and set variables easily
•Simple variable precedence
•Ordered, predictable execution
•Tagged, resumable execution
•ansible doc [foo]
SECURITY
• Can be centralized and locked down via Ansible Tower
• Can be run from a centralized bastion server
• Vault encrypts sensitive data
• Uses ordinary SSH, paramiko or custom transport plugins
• No extra open ports, use your own user account, sudo!
• No agents to update or risk vulnerabilities
ADVANCED CAPABILITIES
• Rolling updates/deployment/orchestration (1, 5, n at a time)
• Canary testing (check for page content or response code)
• Variable timeouts and parellelism
• Ansible-pull to invert execution - nodes check in to a master
MORE INFORMATION
https://docs.ansible.com
https://docs.ansible.com/playbooks_best_practices.html
https://galaxy.ansible.com
https://github.com/ansible/ansible-examples
QUESTIONS?
@steveElsewhere
http://linkedin.com/in/devopsto
THANK YOU!
http://devopsdays.org/events/2015-toronto
(shameless plug)

More Related Content

PPTX
Ansible presentation
Kumar Y
 
PDF
Ansible roles done right
Dan Vaida
 
PPTX
Best practices for ansible
George Shuklin
 
PPT
Tips for a Faster Website
Rayed Alrashed
 
PPTX
Herd your chickens: Ansible for DB2 configuration management
Frederik Engelen
 
PPTX
Introduction to ansible
Omid Vahdaty
 
PDF
Automation with ansible
Khizer Naeem
 
Ansible presentation
Kumar Y
 
Ansible roles done right
Dan Vaida
 
Best practices for ansible
George Shuklin
 
Tips for a Faster Website
Rayed Alrashed
 
Herd your chickens: Ansible for DB2 configuration management
Frederik Engelen
 
Introduction to ansible
Omid Vahdaty
 
Automation with ansible
Khizer Naeem
 

What's hot (20)

PDF
Network Automation: Ansible 102
APNIC
 
PDF
Getting started with Ansible
Ivan Serdyuk
 
PPTX
Ansible presentation
Arthur Freyman
 
PDF
Ansible Meetup Hamburg / Quickstart
Henry Stamerjohann
 
PPT
Ansible presentation
John Lynch
 
PDF
#OktoCampus - Workshop : An introduction to Ansible
Cédric Delgehier
 
PDF
More tips n tricks
bcoca
 
PPTX
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Keith Resar
 
PDF
Ansible, best practices
Bas Meijer
 
PDF
Ansible for beginners ...?
shirou wakayama
 
PDF
Ansible Automation to Rule Them All
Tim Fairweather
 
PDF
Ansible is the simplest way to automate. MoldCamp, 2015
Alex S
 
PDF
IT Automation with Ansible
Rayed Alrashed
 
PPTX
Ansible for beginners
Kuo-Le Mei
 
PDF
Ansible : what's ansible & use case by REX
Saewoong Lee
 
PDF
Jenkins and ansible reference
laonap166
 
PPTX
Introduction to Ansible
CoreStack
 
PDF
AnsibleFest 2014 - Role Tips and Tricks
jimi-c
 
PDF
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
Jumping Bean
 
PDF
V2 and beyond
jimi-c
 
Network Automation: Ansible 102
APNIC
 
Getting started with Ansible
Ivan Serdyuk
 
Ansible presentation
Arthur Freyman
 
Ansible Meetup Hamburg / Quickstart
Henry Stamerjohann
 
Ansible presentation
John Lynch
 
#OktoCampus - Workshop : An introduction to Ansible
Cédric Delgehier
 
More tips n tricks
bcoca
 
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Keith Resar
 
Ansible, best practices
Bas Meijer
 
Ansible for beginners ...?
shirou wakayama
 
Ansible Automation to Rule Them All
Tim Fairweather
 
Ansible is the simplest way to automate. MoldCamp, 2015
Alex S
 
IT Automation with Ansible
Rayed Alrashed
 
Ansible for beginners
Kuo-Le Mei
 
Ansible : what's ansible & use case by REX
Saewoong Lee
 
Jenkins and ansible reference
laonap166
 
Introduction to Ansible
CoreStack
 
AnsibleFest 2014 - Role Tips and Tricks
jimi-c
 
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
Jumping Bean
 
V2 and beyond
jimi-c
 
Ad

Similar to A tour of Ansible (20)

PDF
Ansible with oci
DonghuKIM2
 
PDF
Ansible new paradigms for orchestration
Paolo Tonin
 
PPTX
ansible-app-platforme-2024-presentation-
rimorim
 
PPTX
Ansible presentation
Suresh Kumar
 
PPTX
Automating with Ansible
Ricardo Schmidt
 
PDF
Ansible
Michal Haták
 
PDF
Getting Started with Ansible
ahamilton55
 
PPTX
Introduction to Ansible - (dev ops for people who hate devops)
Jude A. Goonawardena
 
PDF
Puppet: Eclipsecon ALM 2013
grim_radical
 
PDF
Getting Started with Ansible
Ahmed AbouZaid
 
PPTX
Ansible Devops North East - slides
InfinityPP
 
PPTX
Ansible: How to Get More Sleep and Require Less Coffee
Sarah Z
 
PPTX
Go Faster with Ansible (AWS meetup)
Richard Donkin
 
PDF
Ansible not only for Dummies
Łukasz Proszek
 
PDF
Automação do físico ao NetSecDevOps
Raul Leite
 
PDF
20090514 Introducing Puppet To Sasag
garrett honeycutt
 
PDF
Automation day red hat ansible
Rodrigo Missiaggia
 
PDF
infra-as-code
Itamar Hassin
 
PPTX
Go Faster with Ansible (PHP meetup)
Richard Donkin
 
Ansible with oci
DonghuKIM2
 
Ansible new paradigms for orchestration
Paolo Tonin
 
ansible-app-platforme-2024-presentation-
rimorim
 
Ansible presentation
Suresh Kumar
 
Automating with Ansible
Ricardo Schmidt
 
Ansible
Michal Haták
 
Getting Started with Ansible
ahamilton55
 
Introduction to Ansible - (dev ops for people who hate devops)
Jude A. Goonawardena
 
Puppet: Eclipsecon ALM 2013
grim_radical
 
Getting Started with Ansible
Ahmed AbouZaid
 
Ansible Devops North East - slides
InfinityPP
 
Ansible: How to Get More Sleep and Require Less Coffee
Sarah Z
 
Go Faster with Ansible (AWS meetup)
Richard Donkin
 
Ansible not only for Dummies
Łukasz Proszek
 
Automação do físico ao NetSecDevOps
Raul Leite
 
20090514 Introducing Puppet To Sasag
garrett honeycutt
 
Automation day red hat ansible
Rodrigo Missiaggia
 
infra-as-code
Itamar Hassin
 
Go Faster with Ansible (PHP meetup)
Richard Donkin
 
Ad

Recently uploaded (20)

PPTX
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
PDF
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
PPTX
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
PPTX
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
PDF
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
PPTX
Odoo Integration Services by Candidroot Solutions
CandidRoot Solutions Private Limited
 
PDF
Bandai Playdia The Book - David Glotz
BluePanther6
 
PDF
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
PDF
An Experience-Based Look at AI Lead Generation Pricing, Features & B2B Results
Thomas albart
 
PPTX
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
PPTX
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
PPTX
Presentation about variables and constant.pptx
safalsingh810
 
PPTX
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
PPTX
oapresentation.pptx
mehatdhavalrajubhai
 
PDF
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
PDF
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
PDF
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
PDF
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
Odoo Integration Services by Candidroot Solutions
CandidRoot Solutions Private Limited
 
Bandai Playdia The Book - David Glotz
BluePanther6
 
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
An Experience-Based Look at AI Lead Generation Pricing, Features & B2B Results
Thomas albart
 
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
Presentation about variables and constant.pptx
safalsingh810
 
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
oapresentation.pptx
mehatdhavalrajubhai
 
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 

A tour of Ansible

  • 2. Steve Pereira 18 years in IT Startups and Enterprise Love learning about, teaching and talking about: • DevOps • CI/CD • Automation • Scale WHO AM I?
  • 3. ANSIBLE FEATURES • Automation for local and remote system provisioning • Automation for local and remote applications deployment • No agents to install on remote systems • Using existing SSHd on remote systems and native SSH on host • Parallel by default - scale to 6000 targets with single master • Language that approaches plain english
  • 4. ANSIBLE CONVENTIONS Playbooks - contain required tasks to configure systems and deploy Tasks - individual actions to perform on remote or local machines Roles - modular, single-purpose configurations for systems Inventory - files containing address information of target machines Handlers - actions triggered by tasks Templates - customizable files destined for managed machines
  • 5. MINIMUM VIABLE ANSIBLE $ ansible all -i 'localhost,' -c local -m ping localhost | success >> { "changed": false, "ping": "pong" }
  • 6. WHAT ELSE? • ansible webservers -m setup • ansible lb -m copy -a "src=hosts dest=/tmp/hosts” • ansible webservers -m yum -a "name=curl state=installed” • ansible webservers -m service -a "name=nginx state=restarted” • ansible-doc -l
  • 7. PLAYBOOKS--- - hosts: webservers vars: http_port: 80 max_clients: 200 remote_user: root tasks: - name: ensure apache is at the latest version yum: pkg=httpd state=latest - name: write the apache config file template: src=/https/www.slideshare.net/srv/httpd.j2 dest=/etc/httpd.conf notify: - restart apache - name: ensure apache is running (and enable it at boot) service: name=httpd state=started enabled=yes handlers: - name: restart apache service: name=httpd state=restarted example_playbook.yml
  • 8. PLAYBOOKS--- - hosts: webservers vars: http_port: 80 max_clients: 200 remote_user: root tasks: - name: ensure apache is at the latest version yum: pkg=httpd state=latest - name: write the apache config file template: src=/https/www.slideshare.net/srv/httpd.j2 dest=/etc/httpd.conf notify: - restart apache - name: ensure apache is running (and enable it at boot) service: name=httpd state=started enabled=yes handlers: - name: restart apache service: name=httpd state=restarted example_playbook.yml
  • 9. PLAYBOOKS--- - hosts: webservers vars: http_port: 80 max_clients: 200 remote_user: root tasks: - name: ensure apache is at the latest version yum: pkg=httpd state=latest - name: write the apache config file template: src=/https/www.slideshare.net/srv/httpd.j2 dest=/etc/httpd.conf notify: - restart apache - name: ensure apache is running (and enable it at boot) service: name=httpd state=started enabled=yes handlers: - name: restart apache service: name=httpd state=restarted example_playbook.yml
  • 10. PLAYBOOKS--- - hosts: webservers vars: http_port: 80 max_clients: 200 remote_user: root tasks: - name: ensure apache is at the latest version yum: pkg=httpd state=latest - name: write the apache config file template: src=/https/www.slideshare.net/srv/httpd.j2 dest=/etc/httpd.conf notify: - restart apache - name: ensure apache is running (and enable it at boot) service: name=httpd state=started enabled=yes handlers: - name: restart apache service: name=httpd state=restarted example_playbook.yml
  • 11. PLAYBOOKS--- - hosts: webservers vars: http_port: 80 max_clients: 200 remote_user: root tasks: - name: ensure apache is at the latest version yum: pkg=httpd state=latest - name: write the apache config file template: src=/https/www.slideshare.net/srv/httpd.j2 dest=/etc/httpd.conf notify: - restart apache - name: ensure apache is running (and enable it at boot) service: name=httpd state=started enabled=yes handlers: - name: restart apache service: name=httpd state=restarted example_playbook.yml
  • 12. PLAYBOOKS--- - hosts: webservers vars: http_port: 80 max_clients: 200 remote_user: root tasks: - name: ensure apache is at the latest version yum: pkg=httpd state=latest - name: write the apache config file template: src=/https/www.slideshare.net/srv/httpd.j2 dest=/etc/httpd.conf notify: - restart apache - name: ensure apache is running (and enable it at boot) service: name=httpd state=started enabled=yes handlers: - name: restart apache service: name=httpd state=restarted example_playbook.yml
  • 13. PLAYBOOKS--- - hosts: webservers vars: http_port: 80 max_clients: 200 remote_user: root tasks: - name: ensure apache is at the latest version yum: pkg=httpd state=latest - name: write the apache config file template: src=/https/www.slideshare.net/srv/httpd.j2 dest=/etc/httpd.conf notify: - restart apache - name: ensure apache is running (and enable it at boot) service: name=httpd state=started enabled=yes handlers: - name: restart apache service: name=httpd state=restarted example_playbook.yml
  • 14. ROLES my_role/ README.md (readme) defaults/ (default values) meta/ (role metadata) files/ (binaries) templates/ (file templates) handlers/ (operation handlers) tasks/ (playbook files) vars/ (custom variables) • Easily packaged and shared • Download community roles • Mix and match
  • 15. INVENTORY • Define how ansible will interact with remote hosts • Define logical groups of managed nodes • One file for each environment • Default location : /etc/ansible/hosts • INI format, variable overrides sample_inventory.ini [loadbalancers] 10.20.30.41 10.20.30.42 [webservers] 10.20.30.51 hostname=artemis 10.20.30.52 hostname=apollo
  • 16. TEMPLATES • Use Jinja2 templating and variables to customize • Defaults available when variables not provided (dev default with prod override) etc_logrotate.d.j2 {{ logfile }} { rotate {{ 7 | rotate_max }} {{ daily | frequency }} compress missingok notifempty }
  • 17. IT CAN GET FANCY tasks: - name: install packages in a users virtualenv   shell: su - c {{ item[0] }} '(. ./bin/activate && pip install {{ item[1] }})'   with_nested:       - [ 'jim', 'joe', 'jack' ]       - [ package1==1.1,           package2==1.2,           package3==1.3 ] There are several types of loops: Hashes, Fileglobs, Sequence, Subelements, First match, Command results, Random and more but there’s a builtin pip module, anyways.
  • 18. CONDITIONALS tasks: - command: /bin/false register: result ignore_errors:True - command: /bin/something when: result|failed - command: /bin/something_else when: result|success - command: /bin/still/something_else when: result|skipped The result of a play can depend on the value of a variable, fact (something learned about the remote system), or previous task result.
  • 19. MORE CONDITIONALS! tasks: - shell: echo "I've got '{{ foo }}'" when: foo is defined - fail: msg="This play requires 'bar'" when: bar is not defined - command: echo {{ item }} with_items: [ 0, 2, 4, 6, 8, 10 ] when: item > 5 If a required variable has not been set, you can skip or fail using Jinja2’s defined test. For example:
  • 20. SIMPLE, POWERFUL BUILTINS • 261 built-in modules • Many cloud providers, packages and tools are integrated • Easily add your own in any language examples: • ec2 - Create, terminate, start/stop an instance • docker - Manage docker containers • hipchat Send a message to hipchat • s3 - manage objects in S3 • twilio - Sends a text message to a phone • win_service - Manages Windows services • zfs - Manage zfs
  • 21. SMOOTH OPERATION •Get and set variables easily •Simple variable precedence •Ordered, predictable execution •Tagged, resumable execution •ansible doc [foo]
  • 22. SECURITY • Can be centralized and locked down via Ansible Tower • Can be run from a centralized bastion server • Vault encrypts sensitive data • Uses ordinary SSH, paramiko or custom transport plugins • No extra open ports, use your own user account, sudo! • No agents to update or risk vulnerabilities
  • 23. ADVANCED CAPABILITIES • Rolling updates/deployment/orchestration (1, 5, n at a time) • Canary testing (check for page content or response code) • Variable timeouts and parellelism • Ansible-pull to invert execution - nodes check in to a master