SlideShare a Scribd company logo
Introduction to Ansible
Brian Candler
Network Startup Resource Center
brian@nsrc.org
Are your servers Pets or Cattle?
Source:
http://www.slideshare.net/gmccance/cern-data-centre-evolution
What is Ansible?
● A configuration management tool
● Applies changes to your system to bring it to a
desired state
● Similar applications include puppet, chef, salt,
juju, cfengine
Why choose Ansible?
● Target system requires only sshd and python
– No daemons or agents to install
● Security
– Relies on ssh
● Easy to get started, compared to the others!
Ansible running with cowsay
____________________________
< TASK: [install /etc/hosts] >
----------------------------
 ^__^
 (oo)_______
(__) )/
||----w |
|| ||
ok: [pc1.example.com]
Modules
● Ansible “modules” are small pieces of code
which perform one function
– e.g. copy a file, start or stop a daemon
● Most are “idempotent”: means that they only do
something when a change is required
● Many modules supplied as standard
– http://docs.ansible.com/modules.html
Invoking modules from shell
$ ansible s1.ws.nsrc.org -m service 
-a "name=apache2 state=running"
Host or group Module name
Module arguments
Configuring Ansible behaviour
● Tasks are modules called with specific
arguments
● Handlers are triggered when something
changes
– e.g. restart daemon when a config file is changed
● Roles are re-usable bundles of tasks, handlers
and templates
● All defined using YAML
Diversion: YAML
● A way of storing structured data as text
● Conceptually similar to JSON
– String and numeric values
– Lists: ordered sequences
– Hashes: unordered groups of key-value pairs
● String values don't normally need quotes
● Lists and hashes can be nested
● Indentation used to define nesting
YAML list (ordered sequence)
● Single line form
● Multi-line form
[birth, taxes, death]
- birth
- taxes
- death
Space after dash required
YAML hash (key-value pairs)
● Single line form
● Multi-line form
{item: shirt, colour: red, size: 42}
item: shirt
colour: red
size: 42
description: |
this is a very long multi-line
text field which is all one value
Space after colon required
Nesting: list of hashes
● Compact
● Multi-line
- {item: shirt, colour: red, size: 42}
- {item: shirt, colour: blue, size: 44}
- item: shirt
colour: red
size: 42
- item: shirt
colour: blue
size: 44
Note alignment
More complex YAML example
- do: laundry
items:
- trousers
- shirts
- do: polish
items:
- shoes
- buckle
- do: relax
eat:
- chocolate
- chips
A list with 3 items
Each item is a hash (key-value pairs)
Simple value
List value (note indentation)
Ansible playbook
- hosts:
- pc1.example.com
- pc3.example.com
tasks:
- name: install Apache
action: apt pkg=apache2 state=present
- name: ensure Apache is running
action: service name=apache2 state=running
- hosts: dns_servers
roles:
- dns_server
- ntp
Top level: a list of "plays"
Each play has "hosts" plus "tasks" and/or "roles"
Roles
● A bundle of related tasks/handlers/templates
roles/<rolename>/tasks/main.yml
roles/<rolename>/handlers/main.yml
roles/<rolename>/defaults/main.yml
roles/<rolename>/files/...
roles/<rolename>/templates/...
### Recommended way to make re-usable configs
### Not all these files need to be present
Tags
● Each role or individual task can be labelled with
one or more "tags"
● When you run a playbook, you can tell it only to
run tasks with a particular tag: -t <tag>
● Lets you selectively run parts of playbooks
Inventory
● Lists all hosts which Ansible may manage
● Simple "INI" format, not YAML
● Can define groups of hosts
● Default is /etc/ansible/hosts
– We will instead use ./hosts.local
– Can override using -i <filename>
Inventory (hosts) example
[dns_servers]
pc1.example.com
pc2.example.com
[misc]
pc3.example.com
pc4.example.com
# Note: the same host can be listed under
# multiple groups.
# Group "all" is created automatically.
Name of group
Hosts in this group
Inventory variables
● You can set variables on hosts or groups of
hosts
● Variables can make tasks behave differently
when applied to different hosts
● Variables can be inserted into templates
● Some variables control how Ansible connects
Setting host vars
● Directly in the inventory (hosts) file
● In file host_vars/pc2.example.com
[core_servers]
pc1.example.com ansible_connection=local
pc2.example.com
ansible_ssh_host: 10.10.0.241
ansible_ssh_user: root
flurble:
- foo
- bar
# This is in YAML and is preferred
Setting group vars
● group_vars/dns_servers
● group_vars/all
# More YAML
flurble:
- baz
- qux
# More YAML, applies to every host
# Note: host vars take priority over group vars
"Facts"
● Facts are variables containing information
collected automatically about the target host
● Things like what OS is installed, what interfaces
it has, what disk drives it has
● Can be used to adapt roles automatically to the
target system
● Gathered every time Ansible connects to a host
(unless playbook has "gather_facts: no")
Showing facts
$ ansible s1.ws.nsrc.org -m setup | less
s1.ws.nsrc.org | success >> {
"ansible_facts": {
"ansible_distribution": "Ubuntu",
"ansible_distribution_version": "12.04",
"ansible_domain": "ws.nsrc.org",
"ansible_eth0": {
"ipv4": {
"address": "10.10.0.241",
"netmask": "255.255.255.0",
"network": "10.10.0.0"
}, … etc
Invoke the "setup" module
jinja2 template examples
● Insert a variable into text
● Looping over lists
INTERFACES="{{ dhcp_interface }}"
search ws.nsrc.org
{% for host in use_dns_servers %}
nameserver {{ host }}
{% endfor %}
Many other cool features
● Conditionals
● Loops
- action: apt pkg=apache2 state=present
when: ansible_os_family=='Debian'
- action: apt pkg={{item}} state=present
with_items:
- openssh-server
- acpid
- rsync
- telnet
Getting up-to-date Ansible
● Your package manager's version may be old
● For Ubuntu LTS: use the PPA
apt-get install python-software-properties
add-apt-repository ppa:rquillo/ansible
apt-get update
apt-get install ansible
More info and documentation
● http://docs.ansible.com/
● http://docs.ansible.com/faq.html
● http://jinja.pocoo.org/docs/templates/

More Related Content

What's hot

Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
CoreStack
 
Ansible
AnsibleAnsible
Ansible
Vishal Yadav
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
Rayed Alrashed
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansible
Khizer Naeem
 
Ansible 101
Ansible 101Ansible 101
Ansible 101
Gena Mykhailiuta
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
John Lynch
 
Ansible
AnsibleAnsible
Ansible
Knoldus Inc.
 
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
Simplilearn
 
DevOps with Ansible
DevOps with AnsibleDevOps with Ansible
DevOps with Ansible
Swapnil Jain
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
Omid Vahdaty
 
ansible why ?
ansible why ?ansible why ?
ansible why ?
Yashar Esmaildokht
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
Bas Meijer
 
Ansible Automation to Rule Them All
Ansible Automation to Rule Them AllAnsible Automation to Rule Them All
Ansible Automation to Rule Them All
Tim Fairweather
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done right
Dan Vaida
 
Getting started with Ansible
Getting started with AnsibleGetting started with Ansible
Getting started with Ansible
Ivan Serdyuk
 
Ansible
AnsibleAnsible
Ansible
Rahul Bajaj
 
Ansible intro
Ansible introAnsible intro
DevOps Meetup ansible
DevOps Meetup   ansibleDevOps Meetup   ansible
DevOps Meetup ansible
sriram_rajan
 
Accelerating with Ansible
Accelerating with AnsibleAccelerating with Ansible
Accelerating with Ansible
Global Knowledge Training
 

What's hot (20)

Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
Ansible
AnsibleAnsible
Ansible
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansible
 
Ansible 101
Ansible 101Ansible 101
Ansible 101
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Ansible
AnsibleAnsible
Ansible
 
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
 
DevOps with Ansible
DevOps with AnsibleDevOps with Ansible
DevOps with Ansible
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
Ansible
AnsibleAnsible
Ansible
 
ansible why ?
ansible why ?ansible why ?
ansible why ?
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
 
Ansible Automation to Rule Them All
Ansible Automation to Rule Them AllAnsible Automation to Rule Them All
Ansible Automation to Rule Them All
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done right
 
Getting started with Ansible
Getting started with AnsibleGetting started with Ansible
Getting started with Ansible
 
Ansible
AnsibleAnsible
Ansible
 
Ansible intro
Ansible introAnsible intro
Ansible intro
 
DevOps Meetup ansible
DevOps Meetup   ansibleDevOps Meetup   ansible
DevOps Meetup ansible
 
Accelerating with Ansible
Accelerating with AnsibleAccelerating with Ansible
Accelerating with Ansible
 

Viewers also liked

Python (Jinja2) Templates for Network Automation
Python (Jinja2) Templates for Network AutomationPython (Jinja2) Templates for Network Automation
Python (Jinja2) Templates for Network Automation
Rick Sherman
 
Ansible 101, Gennadiy Mykhailiuta
Ansible 101, Gennadiy MykhailiutaAnsible 101, Gennadiy Mykhailiuta
Ansible 101, Gennadiy Mykhailiuta
Tetiana Saputo
 
The Rules of Network Automation - Interop/NYC 2014
The Rules of Network Automation - Interop/NYC 2014The Rules of Network Automation - Interop/NYC 2014
The Rules of Network Automation - Interop/NYC 2014
Jeremy Schulman
 
A Network Engineer's Approach to Automation
A Network Engineer's Approach to AutomationA Network Engineer's Approach to Automation
A Network Engineer's Approach to Automation
Jeremy Schulman
 
Introductory Presentation of bdNOG
Introductory Presentation of bdNOGIntroductory Presentation of bdNOG
Introductory Presentation of bdNOG
Bangladesh Network Operators Group
 
Information Society Innovation Fund (ISIF) Showcase
Information Society Innovation Fund (ISIF) Showcase Information Society Innovation Fund (ISIF) Showcase
Information Society Innovation Fund (ISIF) Showcase
Bangladesh Network Operators Group
 
Driver Distraction Management Using Sensor Data Cloud
Driver Distraction Management Using Sensor Data Cloud Driver Distraction Management Using Sensor Data Cloud
Driver Distraction Management Using Sensor Data Cloud
Bangladesh Network Operators Group
 
Internet Measurement Network
Internet Measurement Network Internet Measurement Network
Internet Measurement Network
Bangladesh Network Operators Group
 
ICANN Security, Stability and Resiliency Plans & Framework
ICANN Security, Stability and Resiliency Plans & Framework ICANN Security, Stability and Resiliency Plans & Framework
ICANN Security, Stability and Resiliency Plans & Framework
Bangladesh Network Operators Group
 
Internet Development Experiences and Lessons
Internet Development Experiences and Lessons Internet Development Experiences and Lessons
Internet Development Experiences and Lessons
Bangladesh Network Operators Group
 
Engaging with Internet Society
Engaging with Internet SocietyEngaging with Internet Society
Engaging with Internet Society
Bangladesh Network Operators Group
 
Network Security Best Practice (BCP38 & 140)
Network Security Best Practice (BCP38 & 140) Network Security Best Practice (BCP38 & 140)
Network Security Best Practice (BCP38 & 140)
Bangladesh Network Operators Group
 
IPv6 Deployment Status in Bangladesh
IPv6 Deployment Status in Bangladesh IPv6 Deployment Status in Bangladesh
IPv6 Deployment Status in Bangladesh
Bangladesh Network Operators Group
 
Discovering and Participating at ICANN
Discovering and Participating at ICANNDiscovering and Participating at ICANN
Discovering and Participating at ICANN
Bangladesh Network Operators Group
 
IRR Toolset, RPSL
IRR Toolset, RPSL IRR Toolset, RPSL
Application of local Internet content
Application of local Internet content Application of local Internet content
Application of local Internet content
Bangladesh Network Operators Group
 
Fast Convergence in IP Network
Fast Convergence in IP Network Fast Convergence in IP Network
Fast Convergence in IP Network
Bangladesh Network Operators Group
 
Cyber Security law in Bangladesh
Cyber Security law in Bangladesh Cyber Security law in Bangladesh
Cyber Security law in Bangladesh
Bangladesh Network Operators Group
 
Distributed IP-PBX
Distributed IP-PBX Distributed IP-PBX
History and Evolution of Bangladesh Internet
History and Evolution of Bangladesh Internet History and Evolution of Bangladesh Internet
History and Evolution of Bangladesh Internet
Bangladesh Network Operators Group
 

Viewers also liked (20)

Python (Jinja2) Templates for Network Automation
Python (Jinja2) Templates for Network AutomationPython (Jinja2) Templates for Network Automation
Python (Jinja2) Templates for Network Automation
 
Ansible 101, Gennadiy Mykhailiuta
Ansible 101, Gennadiy MykhailiutaAnsible 101, Gennadiy Mykhailiuta
Ansible 101, Gennadiy Mykhailiuta
 
The Rules of Network Automation - Interop/NYC 2014
The Rules of Network Automation - Interop/NYC 2014The Rules of Network Automation - Interop/NYC 2014
The Rules of Network Automation - Interop/NYC 2014
 
A Network Engineer's Approach to Automation
A Network Engineer's Approach to AutomationA Network Engineer's Approach to Automation
A Network Engineer's Approach to Automation
 
Introductory Presentation of bdNOG
Introductory Presentation of bdNOGIntroductory Presentation of bdNOG
Introductory Presentation of bdNOG
 
Information Society Innovation Fund (ISIF) Showcase
Information Society Innovation Fund (ISIF) Showcase Information Society Innovation Fund (ISIF) Showcase
Information Society Innovation Fund (ISIF) Showcase
 
Driver Distraction Management Using Sensor Data Cloud
Driver Distraction Management Using Sensor Data Cloud Driver Distraction Management Using Sensor Data Cloud
Driver Distraction Management Using Sensor Data Cloud
 
Internet Measurement Network
Internet Measurement Network Internet Measurement Network
Internet Measurement Network
 
ICANN Security, Stability and Resiliency Plans & Framework
ICANN Security, Stability and Resiliency Plans & Framework ICANN Security, Stability and Resiliency Plans & Framework
ICANN Security, Stability and Resiliency Plans & Framework
 
Internet Development Experiences and Lessons
Internet Development Experiences and Lessons Internet Development Experiences and Lessons
Internet Development Experiences and Lessons
 
Engaging with Internet Society
Engaging with Internet SocietyEngaging with Internet Society
Engaging with Internet Society
 
Network Security Best Practice (BCP38 & 140)
Network Security Best Practice (BCP38 & 140) Network Security Best Practice (BCP38 & 140)
Network Security Best Practice (BCP38 & 140)
 
IPv6 Deployment Status in Bangladesh
IPv6 Deployment Status in Bangladesh IPv6 Deployment Status in Bangladesh
IPv6 Deployment Status in Bangladesh
 
Discovering and Participating at ICANN
Discovering and Participating at ICANNDiscovering and Participating at ICANN
Discovering and Participating at ICANN
 
IRR Toolset, RPSL
IRR Toolset, RPSL IRR Toolset, RPSL
IRR Toolset, RPSL
 
Application of local Internet content
Application of local Internet content Application of local Internet content
Application of local Internet content
 
Fast Convergence in IP Network
Fast Convergence in IP Network Fast Convergence in IP Network
Fast Convergence in IP Network
 
Cyber Security law in Bangladesh
Cyber Security law in Bangladesh Cyber Security law in Bangladesh
Cyber Security law in Bangladesh
 
Distributed IP-PBX
Distributed IP-PBX Distributed IP-PBX
Distributed IP-PBX
 
History and Evolution of Bangladesh Internet
History and Evolution of Bangladesh Internet History and Evolution of Bangladesh Internet
History and Evolution of Bangladesh Internet
 

Similar to Configuration Management in Ansible

Introduction to Ansible - (dev ops for people who hate devops)
Introduction to Ansible - (dev ops for people who hate devops)Introduction to Ansible - (dev ops for people who hate devops)
Introduction to Ansible - (dev ops for people who hate devops)
Jude A. Goonawardena
 
#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible
Cédric Delgehier
 
MariaDB, MySQL and Ansible: automating database infrastructures
MariaDB, MySQL and Ansible: automating database infrastructuresMariaDB, MySQL and Ansible: automating database infrastructures
MariaDB, MySQL and Ansible: automating database infrastructures
Federico Razzoli
 
Introduction to Ansible - Peter Halligan
Introduction to Ansible - Peter HalliganIntroduction to Ansible - Peter Halligan
Introduction to Ansible - Peter Halligan
CorkOpenTech
 
Ansible automation tool with modules
Ansible automation tool with modulesAnsible automation tool with modules
Ansible automation tool with modulesmohamedmoharam
 
Learning Puppet basic thing
Learning Puppet basic thing Learning Puppet basic thing
Learning Puppet basic thing
DaeHyung Lee
 
More tips n tricks
More tips n tricksMore tips n tricks
More tips n tricks
bcoca
 
Introducing Ansible
Introducing AnsibleIntroducing Ansible
Introducing Ansible
Francesco Pantano
 
Ansible & Salt - Vincent Boon
Ansible & Salt - Vincent BoonAnsible & Salt - Vincent Boon
Ansible & Salt - Vincent Boon
MyNOG
 
Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdf
NigussMehari4
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
Mehmet Ali Aydın
 
Ansible is Our Wishbone
Ansible is Our WishboneAnsible is Our Wishbone
Ansible is Our Wishbone
Mydbops
 
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
M Malai
 
Using Ansible for Deploying to Cloud Environments
Using Ansible for Deploying to Cloud EnvironmentsUsing Ansible for Deploying to Cloud Environments
Using Ansible for Deploying to Cloud Environments
ahamilton55
 
Automating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and AnsibleAutomating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and Ansible
Brian Hogan
 
Ansible for beginners
Ansible for beginnersAnsible for beginners
Ansible for beginners
Kuo-Le Mei
 
Workflow story: Theory versus Practice in large enterprises by Marcin Piebiak
Workflow story: Theory versus Practice in large enterprises by Marcin PiebiakWorkflow story: Theory versus Practice in large enterprises by Marcin Piebiak
Workflow story: Theory versus Practice in large enterprises by Marcin Piebiak
NETWAYS
 
Workflow story: Theory versus practice in Large Enterprises
Workflow story: Theory versus practice in Large EnterprisesWorkflow story: Theory versus practice in Large Enterprises
Workflow story: Theory versus practice in Large Enterprises
Puppet
 
Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015
Alex S
 
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
Gulcin Yildirim Jelinek
 

Similar to Configuration Management in Ansible (20)

Introduction to Ansible - (dev ops for people who hate devops)
Introduction to Ansible - (dev ops for people who hate devops)Introduction to Ansible - (dev ops for people who hate devops)
Introduction to Ansible - (dev ops for people who hate devops)
 
#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible
 
MariaDB, MySQL and Ansible: automating database infrastructures
MariaDB, MySQL and Ansible: automating database infrastructuresMariaDB, MySQL and Ansible: automating database infrastructures
MariaDB, MySQL and Ansible: automating database infrastructures
 
Introduction to Ansible - Peter Halligan
Introduction to Ansible - Peter HalliganIntroduction to Ansible - Peter Halligan
Introduction to Ansible - Peter Halligan
 
Ansible automation tool with modules
Ansible automation tool with modulesAnsible automation tool with modules
Ansible automation tool with modules
 
Learning Puppet basic thing
Learning Puppet basic thing Learning Puppet basic thing
Learning Puppet basic thing
 
More tips n tricks
More tips n tricksMore tips n tricks
More tips n tricks
 
Introducing Ansible
Introducing AnsibleIntroducing Ansible
Introducing Ansible
 
Ansible & Salt - Vincent Boon
Ansible & Salt - Vincent BoonAnsible & Salt - Vincent Boon
Ansible & Salt - Vincent Boon
 
Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdf
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
 
Ansible is Our Wishbone
Ansible is Our WishboneAnsible is Our Wishbone
Ansible is Our Wishbone
 
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
 
Using Ansible for Deploying to Cloud Environments
Using Ansible for Deploying to Cloud EnvironmentsUsing Ansible for Deploying to Cloud Environments
Using Ansible for Deploying to Cloud Environments
 
Automating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and AnsibleAutomating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and Ansible
 
Ansible for beginners
Ansible for beginnersAnsible for beginners
Ansible for beginners
 
Workflow story: Theory versus Practice in large enterprises by Marcin Piebiak
Workflow story: Theory versus Practice in large enterprises by Marcin PiebiakWorkflow story: Theory versus Practice in large enterprises by Marcin Piebiak
Workflow story: Theory versus Practice in large enterprises by Marcin Piebiak
 
Workflow story: Theory versus practice in Large Enterprises
Workflow story: Theory versus practice in Large EnterprisesWorkflow story: Theory versus practice in Large Enterprises
Workflow story: Theory versus practice in Large Enterprises
 
Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015
 
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
 

More from Bangladesh Network Operators Group

Accelerating Hyper-Converged Enterprise Virtualization using Proxmox and Ceph
Accelerating Hyper-Converged Enterprise Virtualization using Proxmox and CephAccelerating Hyper-Converged Enterprise Virtualization using Proxmox and Ceph
Accelerating Hyper-Converged Enterprise Virtualization using Proxmox and Ceph
Bangladesh Network Operators Group
 
Recent IRR changes by Yoshinobu Matsuzaki, IIJ
Recent IRR changes by Yoshinobu Matsuzaki, IIJRecent IRR changes by Yoshinobu Matsuzaki, IIJ
Recent IRR changes by Yoshinobu Matsuzaki, IIJ
Bangladesh Network Operators Group
 
Fact Sheets : Network Status in Bangladesh
Fact Sheets : Network Status in BangladeshFact Sheets : Network Status in Bangladesh
Fact Sheets : Network Status in Bangladesh
Bangladesh Network Operators Group
 
AI Driven Wi-Fi for the Bottom of the Pyramid
AI Driven Wi-Fi for the Bottom of the PyramidAI Driven Wi-Fi for the Bottom of the Pyramid
AI Driven Wi-Fi for the Bottom of the Pyramid
Bangladesh Network Operators Group
 
IPv6 Security Overview by QS Tahmeed, APNIC RCT
IPv6 Security Overview by QS Tahmeed, APNIC RCTIPv6 Security Overview by QS Tahmeed, APNIC RCT
IPv6 Security Overview by QS Tahmeed, APNIC RCT
Bangladesh Network Operators Group
 
Network eWaste : Community role to manage end of life Product
Network eWaste : Community role to manage end of life ProductNetwork eWaste : Community role to manage end of life Product
Network eWaste : Community role to manage end of life Product
Bangladesh Network Operators Group
 
A plenarily integrated SIEM solution and it’s Deployment
A plenarily integrated SIEM solution and it’s DeploymentA plenarily integrated SIEM solution and it’s Deployment
A plenarily integrated SIEM solution and it’s Deployment
Bangladesh Network Operators Group
 
IPv6 Deployment in South Asia 2022
IPv6 Deployment in South Asia  2022IPv6 Deployment in South Asia  2022
IPv6 Deployment in South Asia 2022
Bangladesh Network Operators Group
 
Introduction to Software Defined Networking (SDN)
Introduction to Software Defined Networking (SDN)Introduction to Software Defined Networking (SDN)
Introduction to Software Defined Networking (SDN)
Bangladesh Network Operators Group
 
RPKI Deployment Status in Bangladesh
RPKI Deployment Status in BangladeshRPKI Deployment Status in Bangladesh
RPKI Deployment Status in Bangladesh
Bangladesh Network Operators Group
 
An Overview about open UDP Services
An Overview about open UDP ServicesAn Overview about open UDP Services
An Overview about open UDP Services
Bangladesh Network Operators Group
 
12 Years in DNS Security As a Defender
12 Years in DNS Security As a Defender12 Years in DNS Security As a Defender
12 Years in DNS Security As a Defender
Bangladesh Network Operators Group
 
Contents Localization Initiatives to get better User Experience
Contents Localization Initiatives to get better User ExperienceContents Localization Initiatives to get better User Experience
Contents Localization Initiatives to get better User Experience
Bangladesh Network Operators Group
 
BdNOG-20220625-MT-v6.0.pptx
BdNOG-20220625-MT-v6.0.pptxBdNOG-20220625-MT-v6.0.pptx
BdNOG-20220625-MT-v6.0.pptx
Bangladesh Network Operators Group
 
Route Leak Prevension with BGP Community
Route Leak Prevension with BGP CommunityRoute Leak Prevension with BGP Community
Route Leak Prevension with BGP Community
Bangladesh Network Operators Group
 
Tale of a New Bangladeshi NIX
Tale of a New Bangladeshi NIXTale of a New Bangladeshi NIX
Tale of a New Bangladeshi NIX
Bangladesh Network Operators Group
 
MANRS for Network Operators
MANRS for Network OperatorsMANRS for Network Operators
MANRS for Network Operators
Bangladesh Network Operators Group
 
Re-define network visibility for capacity planning & forecasting with Grafana
Re-define network visibility for capacity planning & forecasting with GrafanaRe-define network visibility for capacity planning & forecasting with Grafana
Re-define network visibility for capacity planning & forecasting with Grafana
Bangladesh Network Operators Group
 
RPKI ROA updates
RPKI ROA updatesRPKI ROA updates
Blockchain Demystified
Blockchain DemystifiedBlockchain Demystified
Blockchain Demystified
Bangladesh Network Operators Group
 

More from Bangladesh Network Operators Group (20)

Accelerating Hyper-Converged Enterprise Virtualization using Proxmox and Ceph
Accelerating Hyper-Converged Enterprise Virtualization using Proxmox and CephAccelerating Hyper-Converged Enterprise Virtualization using Proxmox and Ceph
Accelerating Hyper-Converged Enterprise Virtualization using Proxmox and Ceph
 
Recent IRR changes by Yoshinobu Matsuzaki, IIJ
Recent IRR changes by Yoshinobu Matsuzaki, IIJRecent IRR changes by Yoshinobu Matsuzaki, IIJ
Recent IRR changes by Yoshinobu Matsuzaki, IIJ
 
Fact Sheets : Network Status in Bangladesh
Fact Sheets : Network Status in BangladeshFact Sheets : Network Status in Bangladesh
Fact Sheets : Network Status in Bangladesh
 
AI Driven Wi-Fi for the Bottom of the Pyramid
AI Driven Wi-Fi for the Bottom of the PyramidAI Driven Wi-Fi for the Bottom of the Pyramid
AI Driven Wi-Fi for the Bottom of the Pyramid
 
IPv6 Security Overview by QS Tahmeed, APNIC RCT
IPv6 Security Overview by QS Tahmeed, APNIC RCTIPv6 Security Overview by QS Tahmeed, APNIC RCT
IPv6 Security Overview by QS Tahmeed, APNIC RCT
 
Network eWaste : Community role to manage end of life Product
Network eWaste : Community role to manage end of life ProductNetwork eWaste : Community role to manage end of life Product
Network eWaste : Community role to manage end of life Product
 
A plenarily integrated SIEM solution and it’s Deployment
A plenarily integrated SIEM solution and it’s DeploymentA plenarily integrated SIEM solution and it’s Deployment
A plenarily integrated SIEM solution and it’s Deployment
 
IPv6 Deployment in South Asia 2022
IPv6 Deployment in South Asia  2022IPv6 Deployment in South Asia  2022
IPv6 Deployment in South Asia 2022
 
Introduction to Software Defined Networking (SDN)
Introduction to Software Defined Networking (SDN)Introduction to Software Defined Networking (SDN)
Introduction to Software Defined Networking (SDN)
 
RPKI Deployment Status in Bangladesh
RPKI Deployment Status in BangladeshRPKI Deployment Status in Bangladesh
RPKI Deployment Status in Bangladesh
 
An Overview about open UDP Services
An Overview about open UDP ServicesAn Overview about open UDP Services
An Overview about open UDP Services
 
12 Years in DNS Security As a Defender
12 Years in DNS Security As a Defender12 Years in DNS Security As a Defender
12 Years in DNS Security As a Defender
 
Contents Localization Initiatives to get better User Experience
Contents Localization Initiatives to get better User ExperienceContents Localization Initiatives to get better User Experience
Contents Localization Initiatives to get better User Experience
 
BdNOG-20220625-MT-v6.0.pptx
BdNOG-20220625-MT-v6.0.pptxBdNOG-20220625-MT-v6.0.pptx
BdNOG-20220625-MT-v6.0.pptx
 
Route Leak Prevension with BGP Community
Route Leak Prevension with BGP CommunityRoute Leak Prevension with BGP Community
Route Leak Prevension with BGP Community
 
Tale of a New Bangladeshi NIX
Tale of a New Bangladeshi NIXTale of a New Bangladeshi NIX
Tale of a New Bangladeshi NIX
 
MANRS for Network Operators
MANRS for Network OperatorsMANRS for Network Operators
MANRS for Network Operators
 
Re-define network visibility for capacity planning & forecasting with Grafana
Re-define network visibility for capacity planning & forecasting with GrafanaRe-define network visibility for capacity planning & forecasting with Grafana
Re-define network visibility for capacity planning & forecasting with Grafana
 
RPKI ROA updates
RPKI ROA updatesRPKI ROA updates
RPKI ROA updates
 
Blockchain Demystified
Blockchain DemystifiedBlockchain Demystified
Blockchain Demystified
 

Recently uploaded

History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
laozhuseo02
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
3ipehhoa
 
Output determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CCOutput determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CC
ShahulHameed54211
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
nirahealhty
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
3ipehhoa
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
laozhuseo02
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
natyesu
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
JeyaPerumal1
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
Gal Baras
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
Himani415946
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Sanjeev Rampal
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
Rogerio Filho
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
3ipehhoa
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
Arif0071
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
JungkooksNonexistent
 
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptxLiving-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
TristanJasperRamos
 

Recently uploaded (16)

History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
 
Output determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CCOutput determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CC
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
 
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptxLiving-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
 

Configuration Management in Ansible

  • 1. Introduction to Ansible Brian Candler Network Startup Resource Center brian@nsrc.org
  • 2. Are your servers Pets or Cattle? Source: http://www.slideshare.net/gmccance/cern-data-centre-evolution
  • 3. What is Ansible? ● A configuration management tool ● Applies changes to your system to bring it to a desired state ● Similar applications include puppet, chef, salt, juju, cfengine
  • 4. Why choose Ansible? ● Target system requires only sshd and python – No daemons or agents to install ● Security – Relies on ssh ● Easy to get started, compared to the others!
  • 5. Ansible running with cowsay ____________________________ < TASK: [install /etc/hosts] > ---------------------------- ^__^ (oo)_______ (__) )/ ||----w | || || ok: [pc1.example.com]
  • 6. Modules ● Ansible “modules” are small pieces of code which perform one function – e.g. copy a file, start or stop a daemon ● Most are “idempotent”: means that they only do something when a change is required ● Many modules supplied as standard – http://docs.ansible.com/modules.html
  • 7. Invoking modules from shell $ ansible s1.ws.nsrc.org -m service -a "name=apache2 state=running" Host or group Module name Module arguments
  • 8. Configuring Ansible behaviour ● Tasks are modules called with specific arguments ● Handlers are triggered when something changes – e.g. restart daemon when a config file is changed ● Roles are re-usable bundles of tasks, handlers and templates ● All defined using YAML
  • 9. Diversion: YAML ● A way of storing structured data as text ● Conceptually similar to JSON – String and numeric values – Lists: ordered sequences – Hashes: unordered groups of key-value pairs ● String values don't normally need quotes ● Lists and hashes can be nested ● Indentation used to define nesting
  • 10. YAML list (ordered sequence) ● Single line form ● Multi-line form [birth, taxes, death] - birth - taxes - death Space after dash required
  • 11. YAML hash (key-value pairs) ● Single line form ● Multi-line form {item: shirt, colour: red, size: 42} item: shirt colour: red size: 42 description: | this is a very long multi-line text field which is all one value Space after colon required
  • 12. Nesting: list of hashes ● Compact ● Multi-line - {item: shirt, colour: red, size: 42} - {item: shirt, colour: blue, size: 44} - item: shirt colour: red size: 42 - item: shirt colour: blue size: 44 Note alignment
  • 13. More complex YAML example - do: laundry items: - trousers - shirts - do: polish items: - shoes - buckle - do: relax eat: - chocolate - chips A list with 3 items Each item is a hash (key-value pairs) Simple value List value (note indentation)
  • 14. Ansible playbook - hosts: - pc1.example.com - pc3.example.com tasks: - name: install Apache action: apt pkg=apache2 state=present - name: ensure Apache is running action: service name=apache2 state=running - hosts: dns_servers roles: - dns_server - ntp Top level: a list of "plays" Each play has "hosts" plus "tasks" and/or "roles"
  • 15. Roles ● A bundle of related tasks/handlers/templates roles/<rolename>/tasks/main.yml roles/<rolename>/handlers/main.yml roles/<rolename>/defaults/main.yml roles/<rolename>/files/... roles/<rolename>/templates/... ### Recommended way to make re-usable configs ### Not all these files need to be present
  • 16. Tags ● Each role or individual task can be labelled with one or more "tags" ● When you run a playbook, you can tell it only to run tasks with a particular tag: -t <tag> ● Lets you selectively run parts of playbooks
  • 17. Inventory ● Lists all hosts which Ansible may manage ● Simple "INI" format, not YAML ● Can define groups of hosts ● Default is /etc/ansible/hosts – We will instead use ./hosts.local – Can override using -i <filename>
  • 18. Inventory (hosts) example [dns_servers] pc1.example.com pc2.example.com [misc] pc3.example.com pc4.example.com # Note: the same host can be listed under # multiple groups. # Group "all" is created automatically. Name of group Hosts in this group
  • 19. Inventory variables ● You can set variables on hosts or groups of hosts ● Variables can make tasks behave differently when applied to different hosts ● Variables can be inserted into templates ● Some variables control how Ansible connects
  • 20. Setting host vars ● Directly in the inventory (hosts) file ● In file host_vars/pc2.example.com [core_servers] pc1.example.com ansible_connection=local pc2.example.com ansible_ssh_host: 10.10.0.241 ansible_ssh_user: root flurble: - foo - bar # This is in YAML and is preferred
  • 21. Setting group vars ● group_vars/dns_servers ● group_vars/all # More YAML flurble: - baz - qux # More YAML, applies to every host # Note: host vars take priority over group vars
  • 22. "Facts" ● Facts are variables containing information collected automatically about the target host ● Things like what OS is installed, what interfaces it has, what disk drives it has ● Can be used to adapt roles automatically to the target system ● Gathered every time Ansible connects to a host (unless playbook has "gather_facts: no")
  • 23. Showing facts $ ansible s1.ws.nsrc.org -m setup | less s1.ws.nsrc.org | success >> { "ansible_facts": { "ansible_distribution": "Ubuntu", "ansible_distribution_version": "12.04", "ansible_domain": "ws.nsrc.org", "ansible_eth0": { "ipv4": { "address": "10.10.0.241", "netmask": "255.255.255.0", "network": "10.10.0.0" }, … etc Invoke the "setup" module
  • 24. jinja2 template examples ● Insert a variable into text ● Looping over lists INTERFACES="{{ dhcp_interface }}" search ws.nsrc.org {% for host in use_dns_servers %} nameserver {{ host }} {% endfor %}
  • 25. Many other cool features ● Conditionals ● Loops - action: apt pkg=apache2 state=present when: ansible_os_family=='Debian' - action: apt pkg={{item}} state=present with_items: - openssh-server - acpid - rsync - telnet
  • 26. Getting up-to-date Ansible ● Your package manager's version may be old ● For Ubuntu LTS: use the PPA apt-get install python-software-properties add-apt-repository ppa:rquillo/ansible apt-get update apt-get install ansible
  • 27. More info and documentation ● http://docs.ansible.com/ ● http://docs.ansible.com/faq.html ● http://jinja.pocoo.org/docs/templates/