SlideShare a Scribd company logo
What's new in Ansible 2.0
Allan Denot
∙ 2 year experience with Ansible
∙ 3 years experience with AWS
∙ Senior DevOps Engineer at Odecee
∙ Co-founder of spikenode.com
@denot allandenot.com
Allan Denot @denot allandenot.com
∙ Brazilian
∙ 5 years in Australia
New in Ansible 2.0
What’s New
Refactoring
● Improved variable management
● Better use of OOP
● Internal APIs
Many new modules
Language features
Release Date
September 8th:
Testing v2
git clone https://github.com/ansible/ansible.git
cd ansible
. v2/hacking/env-setup
Strategies
- hosts: all
gather_facts: no
strategy: free
tasks:
- pause: seconds={{ 10 |random}}
- debug: msg="msg_1"
- pause: seconds={{ 10 |random}}
- debug: msg="msg_2"
- pause: seconds={{ 10 |random}}
- debug: msg="msg_3"
Execution Strategies
Example playbook:
Execution Strategies
strategy: linear (default)
TASK [debug msg=msg_1]
**********************************************************
ok: [host3] => { "msg": "msg_1", "changed": false}
ok: [host4] => { "msg": "msg_1", "changed": false}
ok: [host2] => { "msg": "msg_1", "changed": false}
ok: [host1] => { "msg": "msg_1", "changed": false}
TASK [debug msg=msg_2]
**********************************************************
ok: [host4] => {"msg": "msg_2", "changed": false}
ok: [host1] => {"msg": "msg_2", "changed": false}
ok: [host2] => {"msg": "msg_2", "changed": false}
ok: [host3] => {"msg": "msg_2", "changed": false}
TASK [debug msg=msg_3]
**********************************************************
ok: [host1] => {"msg": "msg_3", "changed": false}
ok: [host2] => {"msg": "msg_3", "changed": false}
ok: [host3] => {"msg": "msg_3", "changed": false}
ok: [host4] => {"msg": "msg_3", "changed": false}
PLAY [<no name specified>]
******************************************************
ok: [host3] => {"msg": "msg_1", "changed": false}
ok: [host4] => {"msg": "msg_1", "changed": false}
ok: [host2] => {"msg": "msg_1", "changed": false}
ok: [host4] => {"msg": "msg_2", "changed": false}
ok: [host2] => {"msg": "msg_2", "changed": false}
ok: [host4] => {"msg": "msg_3", "changed": false}
ok: [host1] => {"msg": "msg_1", "changed": false}
ok: [host2] => {"msg": "msg_3", "changed": false}
ok: [host3] => {"msg": "msg_2", "changed": false}
ok: [host3] => {"msg": "msg_3", "changed": false}
ok: [host1] => {"msg": "msg_2", "changed": false}
ok: [host1] => {"msg": "msg_3", "changed": false}
strategy: free
Blocks
tasks:
- yum: name={{ item }} state=installed
with_items:
- httpd
- memcached
when: ansible_distribution == 'CentOS'
become: true
become_user: root
- template: src=templates/src.j2 dest=/etc/foo.conf
when: ansible_distribution == 'CentOS'
become: true
become_user: root
- service: name=bar state=started enabled=True
when: ansible_distribution == 'CentOS'
become: true
become_user: root
Blocks
Until 1.9:
REPETITIONREPETITIONREPETITIONREPETITIONREPETITION
tasks:
- block:
- yum: name={{ item }} state=installed
with_items:
- httpd
- memcached
- template: src=templates/src.j2 dest=/etc/foo.conf
- service: name=bar state=started enabled=True
when: ansible_distribution == 'CentOS'
become: true
become_user: root
Blocks
2.0:
tasks:
- block:
- name: Shell script to connect the app to a monitoring service.
script: monitoring-connect.sh
rescue:
- name: This will only run in case of an error in the block.
debug: msg="There was an error in the block."
always:
- name: This will always run, no matter what.
debug: msg="This always executes."
Blocks for Error Handling
2.0:
Modules
Modules
Notorious additions
package - generic OS package manager
- name: install the latest version of ntpdate
package: name=ntpdate state=latest
# This uses a variable as this changes per distro.
- name: remove the apache package
package : name={{apache}} state=absent
expect - executes a command and responds to prompt
- expect:
command: passwd username
responses:
(?i)password: "MySekretPa$$word
find - return a list of files based on criteria
# Recursively find /tmp files older than 4 weeks and equal or greater than 1 megabyte
- find: paths="/tmp" age="4w" size="1m" recurse=yes
# Recursively find /var/tmp files with last access time greater than 3600 seconds
- find: paths="/var/tmp" age="3600" age_stamp=atime recurse=yes
# find /var/log files equal or greater than 10 megabytes ending with .log or .log.gz
- find: paths="/var/tmp" patterns="*.log","*.log.gz" size="10m"
Modules
EC2
iam
ec2_win_password
ec2_ami_find
ec2_ami_copy
ec2_vpc_subnet
ec2_vpc_igw
ecs_task
ecs_cluster
ecs_taskdefinition
ec2_elb_facts
s3_logging
s3_bucket
s3_lifecycle
dynamodb_table
route53_zone
route53_health_check
IAM
EC2 windows
EC2 AMI
VPC
ECS
ELB
S3
DYNAMODB
ROUTE53
Compatibility
Playbooks
Playbooks should be 100% compatible,
no changes required.
Using 2.0 modules TODAY
1 Go to https://github.com/ansible/ansible-modules-core/
Using 2.0 modules TODAY
2 Browse to the module
3
Using 2.0 modules TODAY
4 Save the module file (or copy/paste)
Using 2.0 modules TODAY
5 Save under: library/cloud/amazon/iam2.py
6 Use it normally: tasks:
- name: Create two new IAM users with API keys
iam2:
iam_type: user
name: "{{ item }}"
state: present
password: "{{ temp_pass }}"
access_key_state: create
with_items:
- jcleese
- mpython
And finally...
What's new in Ansible 2.0
There’s a good chance that Tower will be open sourced…
Questions?
Links
github.com/adenot
allandenot.com
spikenode.com

More Related Content

PDF
Ansible with AWS
PDF
How the OOM Killer Deleted My Namespace
PDF
Elasticsearch (R)Evolution — You Know, for Search… by Philipp Krenn at Big Da...
PDF
Apache MXNet Distributed Training Explained In Depth by Viacheslav Kovalevsky...
PPTX
Automating aws infrastructure and code deployments using Ansible @WebEngage
PDF
Docker at OpenDNS
PDF
Docker with BGP - OpenDNS
PDF
Odoo Performance Limits
Ansible with AWS
How the OOM Killer Deleted My Namespace
Elasticsearch (R)Evolution — You Know, for Search… by Philipp Krenn at Big Da...
Apache MXNet Distributed Training Explained In Depth by Viacheslav Kovalevsky...
Automating aws infrastructure and code deployments using Ansible @WebEngage
Docker at OpenDNS
Docker with BGP - OpenDNS
Odoo Performance Limits

What's hot (20)

PPTX
Big data lambda architecture - Streaming Layer Hands On
PPTX
Cyansible
PDF
Kube-AWS
PDF
The Puppet Master on the JVM - PuppetConf 2014
PDF
Kubernetes DNS Horror Stories
PDF
Phoenix for Rails Devs
PDF
VPC by Default時代のアクセス制御
PDF
Making the most out of kubernetes audit logs
PPTX
AWS re:Invent 2014 talk: Scheduling using Apache Mesos in the Cloud
KEY
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
PDF
Building Docker images with Puppet
PDF
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
PDF
An Introduction to Kube-Lego
PDF
Evolution of kube-proxy (Brussels, Fosdem 2020)
PDF
Self Created Load Balancer for MTA on AWS
PDF
DevOps in a Regulated World - aka 'Ansible, AWS, and Jenkins'
PDF
Kubernetes 1.3 - Highlights
PDF
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
PDF
Paris Kafka Meetup - How to develop with Kafka
PDF
Seastar @ SF/BA C++UG
Big data lambda architecture - Streaming Layer Hands On
Cyansible
Kube-AWS
The Puppet Master on the JVM - PuppetConf 2014
Kubernetes DNS Horror Stories
Phoenix for Rails Devs
VPC by Default時代のアクセス制御
Making the most out of kubernetes audit logs
AWS re:Invent 2014 talk: Scheduling using Apache Mesos in the Cloud
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
Building Docker images with Puppet
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
An Introduction to Kube-Lego
Evolution of kube-proxy (Brussels, Fosdem 2020)
Self Created Load Balancer for MTA on AWS
DevOps in a Regulated World - aka 'Ansible, AWS, and Jenkins'
Kubernetes 1.3 - Highlights
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
Paris Kafka Meetup - How to develop with Kafka
Seastar @ SF/BA C++UG
Ad

Similar to What's new in Ansible 2.0 (20)

PDF
Ansible not only for Dummies
PPTX
Learning Puppet basic thing
PDF
Ansible with oci
KEY
fog or: How I Learned to Stop Worrying and Love the Cloud
ODP
Advanced Perl Techniques
KEY
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
PDF
Ansible : what's ansible & use case by REX
PPTX
Ansible for Beginners
KEY
Crafting Beautiful CLI Applications in Ruby
PDF
os lab assignment.pdf
PDF
A tour of Ansible
PDF
Use PEG to Write a Programming Language Parser
PPTX
PDF
MariaDB, MySQL and Ansible: automating database infrastructures
PDF
Ansible loves Python, Python Philadelphia meetup
PDF
Puppet @ Seat
PPTX
Ansible fest Presentation slides
PDF
Puppet fundamentals
PDF
Unit Testing Lots of Perl
Ansible not only for Dummies
Learning Puppet basic thing
Ansible with oci
fog or: How I Learned to Stop Worrying and Love the Cloud
Advanced Perl Techniques
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
Ansible : what's ansible & use case by REX
Ansible for Beginners
Crafting Beautiful CLI Applications in Ruby
os lab assignment.pdf
A tour of Ansible
Use PEG to Write a Programming Language Parser
MariaDB, MySQL and Ansible: automating database infrastructures
Ansible loves Python, Python Philadelphia meetup
Puppet @ Seat
Ansible fest Presentation slides
Puppet fundamentals
Unit Testing Lots of Perl
Ad

Recently uploaded (20)

PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PPT
Module 1.ppt Iot fundamentals and Architecture
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PPTX
cloud_computing_Infrastucture_as_cloud_p
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PPTX
1. Introduction to Computer Programming.pptx
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
Getting started with AI Agents and Multi-Agent Systems
PPTX
O2C Customer Invoices to Receipt V15A.pptx
PDF
Architecture types and enterprise applications.pdf
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
Chapter 5: Probability Theory and Statistics
PDF
2021 HotChips TSMC Packaging Technologies for Chiplets and 3D_0819 publish_pu...
PPTX
Tartificialntelligence_presentation.pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Module 1.ppt Iot fundamentals and Architecture
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
cloud_computing_Infrastucture_as_cloud_p
Final SEM Unit 1 for mit wpu at pune .pptx
1. Introduction to Computer Programming.pptx
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Getting started with AI Agents and Multi-Agent Systems
O2C Customer Invoices to Receipt V15A.pptx
Architecture types and enterprise applications.pdf
A comparative study of natural language inference in Swahili using monolingua...
Assigned Numbers - 2025 - Bluetooth® Document
Chapter 5: Probability Theory and Statistics
2021 HotChips TSMC Packaging Technologies for Chiplets and 3D_0819 publish_pu...
Tartificialntelligence_presentation.pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Univ-Connecticut-ChatGPT-Presentaion.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
How ambidextrous entrepreneurial leaders react to the artificial intelligence...

What's new in Ansible 2.0

  • 1. What's new in Ansible 2.0
  • 2. Allan Denot ∙ 2 year experience with Ansible ∙ 3 years experience with AWS ∙ Senior DevOps Engineer at Odecee ∙ Co-founder of spikenode.com @denot allandenot.com
  • 3. Allan Denot @denot allandenot.com ∙ Brazilian ∙ 5 years in Australia
  • 5. What’s New Refactoring ● Improved variable management ● Better use of OOP ● Internal APIs Many new modules Language features
  • 7. Testing v2 git clone https://github.com/ansible/ansible.git cd ansible . v2/hacking/env-setup
  • 9. - hosts: all gather_facts: no strategy: free tasks: - pause: seconds={{ 10 |random}} - debug: msg="msg_1" - pause: seconds={{ 10 |random}} - debug: msg="msg_2" - pause: seconds={{ 10 |random}} - debug: msg="msg_3" Execution Strategies Example playbook:
  • 10. Execution Strategies strategy: linear (default) TASK [debug msg=msg_1] ********************************************************** ok: [host3] => { "msg": "msg_1", "changed": false} ok: [host4] => { "msg": "msg_1", "changed": false} ok: [host2] => { "msg": "msg_1", "changed": false} ok: [host1] => { "msg": "msg_1", "changed": false} TASK [debug msg=msg_2] ********************************************************** ok: [host4] => {"msg": "msg_2", "changed": false} ok: [host1] => {"msg": "msg_2", "changed": false} ok: [host2] => {"msg": "msg_2", "changed": false} ok: [host3] => {"msg": "msg_2", "changed": false} TASK [debug msg=msg_3] ********************************************************** ok: [host1] => {"msg": "msg_3", "changed": false} ok: [host2] => {"msg": "msg_3", "changed": false} ok: [host3] => {"msg": "msg_3", "changed": false} ok: [host4] => {"msg": "msg_3", "changed": false} PLAY [<no name specified>] ****************************************************** ok: [host3] => {"msg": "msg_1", "changed": false} ok: [host4] => {"msg": "msg_1", "changed": false} ok: [host2] => {"msg": "msg_1", "changed": false} ok: [host4] => {"msg": "msg_2", "changed": false} ok: [host2] => {"msg": "msg_2", "changed": false} ok: [host4] => {"msg": "msg_3", "changed": false} ok: [host1] => {"msg": "msg_1", "changed": false} ok: [host2] => {"msg": "msg_3", "changed": false} ok: [host3] => {"msg": "msg_2", "changed": false} ok: [host3] => {"msg": "msg_3", "changed": false} ok: [host1] => {"msg": "msg_2", "changed": false} ok: [host1] => {"msg": "msg_3", "changed": false} strategy: free
  • 12. tasks: - yum: name={{ item }} state=installed with_items: - httpd - memcached when: ansible_distribution == 'CentOS' become: true become_user: root - template: src=templates/src.j2 dest=/etc/foo.conf when: ansible_distribution == 'CentOS' become: true become_user: root - service: name=bar state=started enabled=True when: ansible_distribution == 'CentOS' become: true become_user: root Blocks Until 1.9: REPETITIONREPETITIONREPETITIONREPETITIONREPETITION
  • 13. tasks: - block: - yum: name={{ item }} state=installed with_items: - httpd - memcached - template: src=templates/src.j2 dest=/etc/foo.conf - service: name=bar state=started enabled=True when: ansible_distribution == 'CentOS' become: true become_user: root Blocks 2.0:
  • 14. tasks: - block: - name: Shell script to connect the app to a monitoring service. script: monitoring-connect.sh rescue: - name: This will only run in case of an error in the block. debug: msg="There was an error in the block." always: - name: This will always run, no matter what. debug: msg="This always executes." Blocks for Error Handling 2.0:
  • 16. Modules Notorious additions package - generic OS package manager - name: install the latest version of ntpdate package: name=ntpdate state=latest # This uses a variable as this changes per distro. - name: remove the apache package package : name={{apache}} state=absent expect - executes a command and responds to prompt - expect: command: passwd username responses: (?i)password: "MySekretPa$$word find - return a list of files based on criteria # Recursively find /tmp files older than 4 weeks and equal or greater than 1 megabyte - find: paths="/tmp" age="4w" size="1m" recurse=yes # Recursively find /var/tmp files with last access time greater than 3600 seconds - find: paths="/var/tmp" age="3600" age_stamp=atime recurse=yes # find /var/log files equal or greater than 10 megabytes ending with .log or .log.gz - find: paths="/var/tmp" patterns="*.log","*.log.gz" size="10m"
  • 19. Playbooks Playbooks should be 100% compatible, no changes required.
  • 20. Using 2.0 modules TODAY 1 Go to https://github.com/ansible/ansible-modules-core/
  • 21. Using 2.0 modules TODAY 2 Browse to the module 3
  • 22. Using 2.0 modules TODAY 4 Save the module file (or copy/paste)
  • 23. Using 2.0 modules TODAY 5 Save under: library/cloud/amazon/iam2.py 6 Use it normally: tasks: - name: Create two new IAM users with API keys iam2: iam_type: user name: "{{ item }}" state: present password: "{{ temp_pass }}" access_key_state: create with_items: - jcleese - mpython
  • 26. There’s a good chance that Tower will be open sourced…