SlideShare a Scribd company logo
Ansible 101
Gennadiy Mykhailiuta,
Ops at Ciklum/Yapital
Kyiv, 2014
Configuration Management
● Identification
define attributes of configuration item, record and baseline
● Change control
set of processes and stages required to change items
attributes
● Status accounting
record and report on configuration baselines at any time
● Audits
ensure that functional or performance attributes of item
achieved
Infrastructure evolution
1 5-10 ...
Deploy Flow Example
What is “Ansible”?
1. Fictional instantaneous hyperspace communication
system featured in Orson Scott Card's Ender's Game.
2. Radically simple IT automation platform.
It can:
a. configure systems
b. deploy software
c. orchestrate advanced IT tasks like
i. continuous deployments or
ii. zero downtime rolling updates
Ansible Design Principles
● Dead simple setup
● No custom agents, open ports, etc
● Minimal learning curve. KISS.
● Manage in parallel
● SSH as transport layer
● Human friendly language - YAML
● Modules in any dynamic language
Install
● From system package:
apt-get/yum install ansible
● From Git repository:
git clone git@github.com:ansible/ansible.git
● From PIP:
pip install ansible
Ad-hoc task
ansible -i hosts -m command -a “uname -r” all
inventory
module name
module
parameters
hosts group
Push vs Pull
Server calls client
Immediate remote
execution
Ansible
Fabric, etc.
Salt
Client calls server
Delayed remote
execution
Chef
CFEngine
Puppet
Salt
Host Inventory: Basic
[web]
web1.example.com
web2.example.com
[db]
dba.example.com
Host Inventory: Advanced
[web]
web[01:16].example.com
[web-secure]
secure.example.com:2222
[service]
tower.example.com ansible_ssh_port=2201 ansible_ssh_user=admin
Host Inventory: Groups
[kyiv]
kv-app-bmw.example.com
kv-app-audi.example.com
[london]
ld-app-jeep.example.com
[europe:children]
kyiv
london
[europe:variables]
shared_files_url=http://192.168.0.250
Host Inventory: Dynamic
● Cloud (EC2, RackSpace)
● Cobbler
● Custom (application)
Playbook.yml example
---
- name: webserver
hosts: web
tasks:
- name: install nginx
yum: name=nginx state=present
- name: ensure nginx runnig
service: name=nginx state=started enabled=yes
Playbook run
# Run
ansible-playbook -i hosts site.yml
# Repeat
play B
Playbook
playbook play A
task 2
task 1
module II
module I
callscontaincontain
Modules
● Input: key=value
● Idempotent
● Can trigger “change events” - handlers
● Can run asynchronous
● Documentation:
ansible-doc yum
● Can be written in any language
Modules: Shell
- name: redirect command output to file
shell: /usr/bin/somecommand &> /tmp/out.log
Modules: Copy
- copy: src=/https/www.slideshare.net/mine/ntp.conf dest=/etc/ntp.conf
owner=root group=root
mode=644 backup=yes
Note multiline.
Modules: Yum
- name: update system
yum: name=* state=latest
Loops
- name: Install php-fpm and deps
yum: name={{ item }} state=present
with_items:
- php
- php-fpm
- php-enchant
Conditionals
- shell: echo "only on Red Hat 6+"
when: ansible_os_family == "RedHat" and
ansible_lsb.major_release|int >= 6
Modules: Setup
ansible -i hosts -m setup web1
Variables
- hosts: web
vars:
remote_install_path: /opt/myapp
tasks:
- template: src=foo.cfg.j2 dest={{ remote_install_path }}/foo.cfg
- command: echo “My IP is {{ ansible_default_ipv4.address }}”
Variables: Sources
● Playbooks
● Inventory (group vars, host vars)
● Command line (-e “varname=value”)
● Discovered facts (module “setup”)
ansible -m setup -u root vm1
Template Example
<?php
/** The name of the database for WordPress */
define('DB_NAME', '{{ wp_db_name }}');
/** MySQL database username */
define('DB_USER', '{{ wp_db_user }}');
/** MySQL database password */
define('DB_PASSWORD', '{{ wp_db_password }}');
…
?>
Modules: Template
- name: Copy nginx configuration
template: src=default.conf
dest=/etc/nginx/conf.d/default.conf
Handlers
...
tasks:
- name: Copy nginx configuration
template: src=default.conf
dest=/etc/nginx/conf.d/default.conf
notify: restart nginx
...
handlers:
- name: restart nginx
service: name=nginx state=restarted
Modules: Lineinfile
- lineinfile: dest=/etc/hosts regexp='^127.0.0.1'
line='127.0.0.1 localhost'
owner=root group=root mode=0644
Playbook
---
- name: install web server
hosts: web
tasks:
- name: ensure nginx is latest
yum: name=nginx state=latest
- name: ensure nginx is running
service: name=nginx state=started
Playbook
Play
Tasks
Roles
├── site.yml
├── hosts
├── roles
│ ├── common
│ │ ├── files
│ │ │ ├── epel.repo
│ │ ├── handlers
│ │ │ └── main.yml
│ │ └── tasks
│ │ └── main.yml
│ ├── nginx
│ │ ├── handlers
│ │ │ └── main.yml
│ │ ├── tasks
│ │ │ └── main.yml
│ │ └── templates
│ │ └── default.conf
---
- hosts: web
roles:
- common
- nginx
---
- name: restart nginx
service: name=nginx state=restarted
---
- name: Install nginx
yum: name=nginx state=present
...
Also
● ansible-galaxy
● ansible-vault
● ansible-lint
● ansible-vagrant
Refereces
● ansible.com
● docs.ansible.com
● github.com/ansible/ansible-examples
● slideshare.net/ShapeBlue/ansible-cseug-
jan2014
● infoq.com/articles/ansible-view-on-it-
automation
Thank you!

More Related Content

PDF
Automation with ansible
PPTX
Ansible presentation
PDF
Ansible
PPTX
Introduction to ansible
PDF
Top Trends in Application Architecture That Enable.pdf
PPTX
Methods of Teaching Science
PDF
Ansible - Hands on Training
PDF
VXLAN BGP EVPN: Technology Building Blocks
Automation with ansible
Ansible presentation
Ansible
Introduction to ansible
Top Trends in Application Architecture That Enable.pdf
Methods of Teaching Science
Ansible - Hands on Training
VXLAN BGP EVPN: Technology Building Blocks

What's hot (20)

PDF
Ansible Introduction
PPTX
Automating with Ansible
ODP
ansible why ?
PDF
Ansible
PPT
Ansible presentation
PDF
Ansible - Introduction
PPTX
Introduction to Ansible
PDF
Ansible
PDF
Ansible, best practices
PDF
DevOps Meetup ansible
PDF
IT Automation with Ansible
PPTX
Introduction to helm
PDF
Ansible
PPTX
Ansible Automation - Enterprise Use Cases | Juncheng Anthony Lin
PDF
Red hat ansible automation technical deck
PDF
Ansible
ODP
Introduction to Ansible
PPTX
Introduction to kubernetes
PPTX
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
Ansible Introduction
Automating with Ansible
ansible why ?
Ansible
Ansible presentation
Ansible - Introduction
Introduction to Ansible
Ansible
Ansible, best practices
DevOps Meetup ansible
IT Automation with Ansible
Introduction to helm
Ansible
Ansible Automation - Enterprise Use Cases | Juncheng Anthony Lin
Red hat ansible automation technical deck
Ansible
Introduction to Ansible
Introduction to kubernetes
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
Ad

Viewers also liked (6)

PDF
Orchestration with Ansible at Fedora Project
PDF
Ansible 101 - Presentation at Ansible STL Meetup
PPTX
Introduccion a Ansible
PDF
Cobbler - Fast and reliable multi-OS provisioning
PPTX
Go Faster with Ansible (PHP meetup)
PDF
Python - code quality and production monitoring
Orchestration with Ansible at Fedora Project
Ansible 101 - Presentation at Ansible STL Meetup
Introduccion a Ansible
Cobbler - Fast and reliable multi-OS provisioning
Go Faster with Ansible (PHP meetup)
Python - code quality and production monitoring
Ad

Similar to Ansible 101 (20)

PDF
A tour of Ansible
PDF
#OktoCampus - Workshop : An introduction to Ansible
PDF
Cobbler, Func and Puppet: Tools for Large Scale Environments
PDF
Cobbler, Func and Puppet: Tools for Large Scale Environments
PDF
OSDC 2014: Jan-Piet Mens - Configuration Management with Ansible
PDF
Ansible Automation to Rule Them All
PDF
OSDC 2013 | Ansible: configuration management doesn't have to be complicated ...
PDF
Ansible - Swiss Army Knife Orchestration
PDF
Ansible is the simplest way to automate. SymfonyCafe, 2015
PDF
OpenNebula, the foreman and CentOS play nice, too
PDF
PLNOG14: Automation at Brainly - Paweł Rozlach
PDF
PLNOG Automation@Brainly
PDF
TechWiseTV Workshop: Catalyst Switching Programmability
PDF
Ansible is the simplest way to automate. MoldCamp, 2015
PDF
php & performance
PPTX
Virtualization and automation of library software/machines + Puppet
PDF
An Introduction To Linux
PDF
PHP & Performance
PPTX
Ansible: How to Get More Sleep and Require Less Coffee
PDF
Tuning systemd for embedded
A tour of Ansible
#OktoCampus - Workshop : An introduction to Ansible
Cobbler, Func and Puppet: Tools for Large Scale Environments
Cobbler, Func and Puppet: Tools for Large Scale Environments
OSDC 2014: Jan-Piet Mens - Configuration Management with Ansible
Ansible Automation to Rule Them All
OSDC 2013 | Ansible: configuration management doesn't have to be complicated ...
Ansible - Swiss Army Knife Orchestration
Ansible is the simplest way to automate. SymfonyCafe, 2015
OpenNebula, the foreman and CentOS play nice, too
PLNOG14: Automation at Brainly - Paweł Rozlach
PLNOG Automation@Brainly
TechWiseTV Workshop: Catalyst Switching Programmability
Ansible is the simplest way to automate. MoldCamp, 2015
php & performance
Virtualization and automation of library software/machines + Puppet
An Introduction To Linux
PHP & Performance
Ansible: How to Get More Sleep and Require Less Coffee
Tuning systemd for embedded

Recently uploaded (20)

PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
Structs to JSON How Go Powers REST APIs.pdf
PDF
B.Tech (Electrical Engineering ) 2024 syllabus.pdf
PDF
Geotechnical Engineering, Soil mechanics- Soil Testing.pdf
PPTX
Internship_Presentation_Final engineering.pptx
PPTX
Glazing at Facade, functions, types of glazing
PPT
Ppt for engineering students application on field effect
PPTX
meets orient on the new industry intereacting skills .pptx
PDF
Top 10 read articles In Managing Information Technology.pdf
PDF
July 2025: Top 10 Read Articles Advanced Information Technology
PDF
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
PPTX
TE-AI-Unit VI notes using planning model
PPT
Chapter 6 Design in software Engineeing.ppt
PPTX
AgentX UiPath Community Webinar series - Delhi
PDF
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
PPTX
ANIMAL INTERVENTION WARNING SYSTEM (4).pptx
PDF
A Framework for Securing Personal Data Shared by Users on the Digital Platforms
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Structs to JSON How Go Powers REST APIs.pdf
B.Tech (Electrical Engineering ) 2024 syllabus.pdf
Geotechnical Engineering, Soil mechanics- Soil Testing.pdf
Internship_Presentation_Final engineering.pptx
Glazing at Facade, functions, types of glazing
Ppt for engineering students application on field effect
meets orient on the new industry intereacting skills .pptx
Top 10 read articles In Managing Information Technology.pdf
July 2025: Top 10 Read Articles Advanced Information Technology
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
TE-AI-Unit VI notes using planning model
Chapter 6 Design in software Engineeing.ppt
AgentX UiPath Community Webinar series - Delhi
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ANIMAL INTERVENTION WARNING SYSTEM (4).pptx
A Framework for Securing Personal Data Shared by Users on the Digital Platforms

Ansible 101