Why Ansible?
What is Ansible?
Ansible - Pull configuration tool
Ansible architecture
Playbook
What’s in it for you?
Inventory
Working of Ansible
Ansible Tower
Use case by Hootsuite
Why Ansible?
This is Sam, a system administrator. He is
responsible for his company’s infrastructure
Why Ansible?
[Web Servers]
[Database Servers]
Why Ansible?
He must install Apache on all the 3 web servers and
MySQL on the two database servers
[Web Servers]
[Database Servers]
Why Ansible?
That’s easy! Wouldn’t take much time either
[Web Servers]
[Database Servers]
Why Ansible?
But what if the number of servers increase?
[Web Servers]
[Database Servers]
The same task must be repeated multiple times.
Moreover, humans are prone to make errors
Why Ansible?
[Web Servers]
[Database Servers]
Why Ansible?
This is where Ansible comes to the rescue
[Web Servers]
[Database Servers]
Why Ansible?
With Ansible, a code is written once for the
installation and deployed multiple times
[Web Servers]
[Database Servers]
Why Ansible?
Sam can now work on more productive tasks rather
than the repetitive ones
[Web Servers]
[Database Servers]
What is Ansible?
Sounds great, right?
But what is Ansible?
What is Ansible?
IT automation
What is Ansible?
Instructions are written to
automate the IT
professional’s work
Ansible is a tool that provides:
IT automation Configuration management
What is Ansible?
Instructions are written to
automate the IT
professional’s work
Consistency of all
systems in the
infrastructure is
maintained
Ansible is a tool that provides:
Ansible is a tool that provides:
IT automation
Instructions are written to
automate the IT
professional’s work
Configuration management
Consistency of all
systems in the
infrastructure is
maintained
Automatic deployment
Applications are deployed
automatically on a variety
of environments
What is Ansible?
Ansible - Pull configuration tool
Pull configuration: Nodes check with the server periodically
and fetch the configurations from it
Ansible - Pull configuration tool
Pull configuration: Nodes check with the server periodically
and fetch the configurations from it
Push configuration: Server pushes configuration to
the nodes
Ansible - Pull configuration tool
Push configuration: Server pushes configuration to
the nodes
Unlike Chef and Puppet, Ansible is push
type configuration management tool
Ansible - Pull configuration tool
Ansible architecture
Local Machine
Node
Module
Inventory Node
Node
The local machine is where Ansible is installed
Ansible architecture
Ansible architecture
Local Machine
Node
Module
Inventory Node
Node
Nodes are the systems to be configured. They are
controlled by the local machine
Ansible architecture
Local Machine
Node
Module
Inventory Node
Node
Module is a collection of configuration code files
Playbooks
Ansible architecture
Local Machine
Node
Module
Inventory Node
Node
These configuration code files are called playbooks
Ansible architecture
Local Machine
Node
Module
Inventory Node
Node
Inventory is a document that groups the nodes under
specific labels
Playbooks
Ansible architecture
Local Machine
Node
Module
Inventory Node
Node
The local machine connects to the nodes through an SSH
client
SSH
Playbooks
Playbook
The core of Ansible
is it’s playbook
Playbook
Playbook
So, what is a
playbook?
Playbook
Playbook
Playbook
Playbooks are the instructions to
configure the nodes
Playbook
Playbook
Playbooks are the instructions to
configure the nodes
They are written in YAML, a language
used to describe data
Playbook
Did you know, YAML
stands for “YAML Ain’t
Markup Language”
Playbook
Playbooks are the instructions to
configure the nodes
They are written in YAML, a language
used to describe data
Playbook
Let’s have a look at the
structure of a playbook
Playbook
Playbooks are the instructions to
configure the nodes
They are written in YAML, a language
used to describe data
Playbook
Let’s have a look at the
structure of a playbook
---
-name: play 1
hosts: webserver
tasks:
-name: install apache
yum:
name: apache
state: present
-name: start apache
service:
name: apache
state: start
-name: play 2
hosts: databaseserver
tasks:
-name: install MySQL
yum:
name: MySQL
state: present
Playbook
Playbook begins with ‘--
-’
---
-name: play 1
hosts: webserver
tasks:
-name: install apache
yum:
name: apache
state: present
-name: start apache
service:
name: apache
state: start
-name: play 2
hosts: databaseserver
tasks:
-name: install MySQL
yum:
name: MySQL
state: present
Playbook
A playbook is a list of
plays
---
-name: play 1
hosts: webserver
tasks:
-name: install apache
yum:
name: apache
state: present
-name: start apache
service:
name: apache
state: start
-name: play 2
hosts: databaseserver
tasks:
-name: install MySQL
yum:
name: MySQL
state: present
Playbook
Host is the target for the
play
---
-name: play 1
hosts: webserver
tasks:
-name: install apache
yum:
name: apache
state: present
-name: start apache
service:
name: apache
state: start
-name: play 2
hosts: databaseserver
tasks:
-name: install MySQL
yum:
name: MySQL
state: present
Playbook
Each play has a list of
tasks
---
-name: play 1
hosts: webserver
tasks:
-name: install apache
yum:
name: apache
state: present
-name: start apache
service:
name: apache
state: start
-name: play 2
hosts: databaseserver
tasks:
-name: install MySQL
yum:
name: MySQL
state: present
Playbook
Each element in the list
of tasks is given a name
---
-name: play 1
hosts: webserver
tasks:
-name: install apache
yum:
name: apache
state: present
-name: start apache
service:
name: apache
state: start
-name: play 2
hosts: databaseserver
tasks:
-name: install MySQL
yum:
name: MySQL
state: present
Playbook
The name is followed by
instructions to execute
the task
---
-name: play 1
hosts: webserver
tasks:
-name: install apache
yum:
name: apache
state: present
-name: start apache
service:
name: apache
state: start
-name: play 2
hosts: databaseserver
tasks:
-name: install MySQL
yum:
name: MySQL
state: present
Playbook
Have a look at the first
task
---
-name: play 1
hosts: webserver
tasks:
-name: install apache
yum:
name: apache
state: present
-name: start apache
service:
name: apache
state: start
-name: play 2
hosts: databaseserver
tasks:
-name: install MySQL
yum:
name: MySQL
state: present
Playbook
Module yum is used to
install the apache
service
---
-name: play 1
hosts: webserver
tasks:
-name: install apache
yum:
name: apache
state: present
-name: start apache
service:
name: apache
state: start
-name: play 2
hosts: databaseserver
tasks:
-name: install MySQL
yum:
name: MySQL
state: present
Playbook
Simple, isn’t it?
---
-name: play 1
hosts: webserver
tasks:
-name: install apache
yum:
name: apache
state: present
-name: start apache
service:
name: apache
state: start
-name: play 2
hosts: databaseserver
tasks:
-name: install MySQL
yum:
name: MySQL
state: present
Playbook
But where do these host
names come from?
---
-name: play 1
hosts: webserver
tasks:
-name: install apache
yum:
name: apache
state: present
-name: start apache
service:
name: apache
state: start
-name: play 2
hosts: databaseserver
tasks:
-name: install MySQL
yum:
name: MySQL
state: present
Playbook
Inventory
This is why we have an
inventory
Inventory
An inventory file
classifies nodes into
groups
[webserver]
web1.machine
web2.machine
web3.machine
[databaseserver]
db1.machine
Inventory
We have two groups
here: ‘webserver’ and
‘databaseserver’
[webserver]
web1.machine
web2.machine
web3.machine
[databaseserver]
db1.machine
Inventory
The hostnames of the
nodes are specified
under the group name
[webserver]
web1.machine
web2.machine
web3.machine
[databaseserver]
db1.machine
Inventory
Working of Ansible
Local Machine
NodeNode Node
Ansible is installed only on the local machine.
This makes Ansible agentless
Working of Ansible
Local Machine
NodeNode Node
The playbook and inventory are written at the
local machine
Working of Ansible
Local Machine
NodeNode Node
The local machine connects to the nodes
through SSH
SS
H
Working of Ansible
Local Machine
NodeNode Node
The local machine gathers the facts of each
node. Facts indicate the state of the nodes
SS
H
Working of Ansible
Local Machine
NodeNode Node
The playbooks are sent to the nodes
SS
H
Working of Ansible
Local Machine
NodeNode Node
The playbooks are now executed. This
configures the nodes to their desired states
SS
H
Working of Ansible
Working of Ansible
So, let’s see if you can
answer a simple
question…
Working of Ansible
What is the major
leverage Ansible has
over Chef and Puppet?
Working of Ansible
Leave your answers on
the comment!
Ansible Tower
Now, let’s have a look at
the icing on the cake-
Ansible Tower!
Ansible Tower
Ansible Tower is a framework for Ansible
Ansible Tower
Ansible Tower is a framework for Ansible
It provides a GUI. Thus, reducing the
dependency on the command prompt
window
Ansible Tower
Ansible Tower is a framework for Ansible
It provides a GUI. Thus, reducing the
dependency on the command prompt
window
Instead of typing long commands, tasks
can now be performed in a single click
Ansible Tower
Use case by Hootsuite
Hootsuite is a social media
management system
Use case by Hootsuite
They assist businesses in
campaigning across
social media platforms
Use case by Hootsuite
But as they gained
popularity, a crisis struck
Use case by Hootsuite
Servers had to be rebuilt continuously
Use case by Hootsuite
Unfortunately, there was no standard
documentation and the entire process
relied on memory
Use case by Hootsuite
This is when the need for Ansible was
realised
Use case by Hootsuite
Now, playbooks are written to deploy
servers providing a standardization
Use case by Hootsuite
Servers are built and rebuilt in a matter of
seconds
Use case by Hootsuite
Use case by Hootsuite
Servers are built and rebuilt in a matter of
seconds
Key Takeaways
Ansible- pull configuration tool
Ansible architecture
What is ansible?Why ansible?
playbook Inventory
Key Takeaways
Ansible towerWorking of ansible Use case by hootsuite
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevOps Tools | Simplilearn

What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevOps Tools | Simplilearn

  • 2.
    Why Ansible? What isAnsible? Ansible - Pull configuration tool Ansible architecture Playbook What’s in it for you? Inventory Working of Ansible Ansible Tower Use case by Hootsuite
  • 3.
  • 4.
    This is Sam,a system administrator. He is responsible for his company’s infrastructure Why Ansible? [Web Servers] [Database Servers]
  • 5.
    Why Ansible? He mustinstall Apache on all the 3 web servers and MySQL on the two database servers [Web Servers] [Database Servers]
  • 6.
    Why Ansible? That’s easy!Wouldn’t take much time either [Web Servers] [Database Servers]
  • 7.
    Why Ansible? But whatif the number of servers increase? [Web Servers] [Database Servers]
  • 8.
    The same taskmust be repeated multiple times. Moreover, humans are prone to make errors Why Ansible? [Web Servers] [Database Servers]
  • 9.
    Why Ansible? This iswhere Ansible comes to the rescue [Web Servers] [Database Servers]
  • 10.
    Why Ansible? With Ansible,a code is written once for the installation and deployed multiple times [Web Servers] [Database Servers]
  • 11.
    Why Ansible? Sam cannow work on more productive tasks rather than the repetitive ones [Web Servers] [Database Servers]
  • 12.
  • 13.
    Sounds great, right? Butwhat is Ansible? What is Ansible?
  • 14.
    IT automation What isAnsible? Instructions are written to automate the IT professional’s work Ansible is a tool that provides:
  • 15.
    IT automation Configurationmanagement What is Ansible? Instructions are written to automate the IT professional’s work Consistency of all systems in the infrastructure is maintained Ansible is a tool that provides:
  • 16.
    Ansible is atool that provides: IT automation Instructions are written to automate the IT professional’s work Configuration management Consistency of all systems in the infrastructure is maintained Automatic deployment Applications are deployed automatically on a variety of environments What is Ansible?
  • 17.
    Ansible - Pullconfiguration tool
  • 18.
    Pull configuration: Nodescheck with the server periodically and fetch the configurations from it Ansible - Pull configuration tool
  • 19.
    Pull configuration: Nodescheck with the server periodically and fetch the configurations from it Push configuration: Server pushes configuration to the nodes Ansible - Pull configuration tool
  • 20.
    Push configuration: Serverpushes configuration to the nodes Unlike Chef and Puppet, Ansible is push type configuration management tool Ansible - Pull configuration tool
  • 21.
  • 22.
    Local Machine Node Module Inventory Node Node Thelocal machine is where Ansible is installed Ansible architecture
  • 23.
    Ansible architecture Local Machine Node Module InventoryNode Node Nodes are the systems to be configured. They are controlled by the local machine
  • 24.
    Ansible architecture Local Machine Node Module InventoryNode Node Module is a collection of configuration code files
  • 25.
    Playbooks Ansible architecture Local Machine Node Module InventoryNode Node These configuration code files are called playbooks
  • 26.
    Ansible architecture Local Machine Node Module InventoryNode Node Inventory is a document that groups the nodes under specific labels Playbooks
  • 27.
    Ansible architecture Local Machine Node Module InventoryNode Node The local machine connects to the nodes through an SSH client SSH Playbooks
  • 28.
  • 29.
    The core ofAnsible is it’s playbook Playbook Playbook
  • 30.
    So, what isa playbook? Playbook Playbook
  • 31.
    Playbook Playbooks are theinstructions to configure the nodes Playbook
  • 32.
    Playbook Playbooks are theinstructions to configure the nodes They are written in YAML, a language used to describe data Playbook
  • 33.
    Did you know,YAML stands for “YAML Ain’t Markup Language” Playbook Playbooks are the instructions to configure the nodes They are written in YAML, a language used to describe data Playbook
  • 34.
    Let’s have alook at the structure of a playbook Playbook Playbooks are the instructions to configure the nodes They are written in YAML, a language used to describe data Playbook
  • 35.
    Let’s have alook at the structure of a playbook --- -name: play 1 hosts: webserver tasks: -name: install apache yum: name: apache state: present -name: start apache service: name: apache state: start -name: play 2 hosts: databaseserver tasks: -name: install MySQL yum: name: MySQL state: present Playbook
  • 36.
    Playbook begins with‘-- -’ --- -name: play 1 hosts: webserver tasks: -name: install apache yum: name: apache state: present -name: start apache service: name: apache state: start -name: play 2 hosts: databaseserver tasks: -name: install MySQL yum: name: MySQL state: present Playbook
  • 37.
    A playbook isa list of plays --- -name: play 1 hosts: webserver tasks: -name: install apache yum: name: apache state: present -name: start apache service: name: apache state: start -name: play 2 hosts: databaseserver tasks: -name: install MySQL yum: name: MySQL state: present Playbook
  • 38.
    Host is thetarget for the play --- -name: play 1 hosts: webserver tasks: -name: install apache yum: name: apache state: present -name: start apache service: name: apache state: start -name: play 2 hosts: databaseserver tasks: -name: install MySQL yum: name: MySQL state: present Playbook
  • 39.
    Each play hasa list of tasks --- -name: play 1 hosts: webserver tasks: -name: install apache yum: name: apache state: present -name: start apache service: name: apache state: start -name: play 2 hosts: databaseserver tasks: -name: install MySQL yum: name: MySQL state: present Playbook
  • 40.
    Each element inthe list of tasks is given a name --- -name: play 1 hosts: webserver tasks: -name: install apache yum: name: apache state: present -name: start apache service: name: apache state: start -name: play 2 hosts: databaseserver tasks: -name: install MySQL yum: name: MySQL state: present Playbook
  • 41.
    The name isfollowed by instructions to execute the task --- -name: play 1 hosts: webserver tasks: -name: install apache yum: name: apache state: present -name: start apache service: name: apache state: start -name: play 2 hosts: databaseserver tasks: -name: install MySQL yum: name: MySQL state: present Playbook
  • 42.
    Have a lookat the first task --- -name: play 1 hosts: webserver tasks: -name: install apache yum: name: apache state: present -name: start apache service: name: apache state: start -name: play 2 hosts: databaseserver tasks: -name: install MySQL yum: name: MySQL state: present Playbook
  • 43.
    Module yum isused to install the apache service --- -name: play 1 hosts: webserver tasks: -name: install apache yum: name: apache state: present -name: start apache service: name: apache state: start -name: play 2 hosts: databaseserver tasks: -name: install MySQL yum: name: MySQL state: present Playbook
  • 44.
    Simple, isn’t it? --- -name:play 1 hosts: webserver tasks: -name: install apache yum: name: apache state: present -name: start apache service: name: apache state: start -name: play 2 hosts: databaseserver tasks: -name: install MySQL yum: name: MySQL state: present Playbook
  • 45.
    But where dothese host names come from? --- -name: play 1 hosts: webserver tasks: -name: install apache yum: name: apache state: present -name: start apache service: name: apache state: start -name: play 2 hosts: databaseserver tasks: -name: install MySQL yum: name: MySQL state: present Playbook
  • 46.
  • 47.
    This is whywe have an inventory Inventory
  • 48.
    An inventory file classifiesnodes into groups [webserver] web1.machine web2.machine web3.machine [databaseserver] db1.machine Inventory
  • 49.
    We have twogroups here: ‘webserver’ and ‘databaseserver’ [webserver] web1.machine web2.machine web3.machine [databaseserver] db1.machine Inventory
  • 50.
    The hostnames ofthe nodes are specified under the group name [webserver] web1.machine web2.machine web3.machine [databaseserver] db1.machine Inventory
  • 51.
  • 52.
    Local Machine NodeNode Node Ansibleis installed only on the local machine. This makes Ansible agentless Working of Ansible
  • 53.
    Local Machine NodeNode Node Theplaybook and inventory are written at the local machine Working of Ansible
  • 54.
    Local Machine NodeNode Node Thelocal machine connects to the nodes through SSH SS H Working of Ansible
  • 55.
    Local Machine NodeNode Node Thelocal machine gathers the facts of each node. Facts indicate the state of the nodes SS H Working of Ansible
  • 56.
    Local Machine NodeNode Node Theplaybooks are sent to the nodes SS H Working of Ansible
  • 57.
    Local Machine NodeNode Node Theplaybooks are now executed. This configures the nodes to their desired states SS H Working of Ansible
  • 58.
    Working of Ansible So,let’s see if you can answer a simple question…
  • 59.
    Working of Ansible Whatis the major leverage Ansible has over Chef and Puppet?
  • 60.
    Working of Ansible Leaveyour answers on the comment!
  • 61.
  • 62.
    Now, let’s havea look at the icing on the cake- Ansible Tower! Ansible Tower
  • 63.
    Ansible Tower isa framework for Ansible Ansible Tower
  • 64.
    Ansible Tower isa framework for Ansible It provides a GUI. Thus, reducing the dependency on the command prompt window Ansible Tower
  • 65.
    Ansible Tower isa framework for Ansible It provides a GUI. Thus, reducing the dependency on the command prompt window Instead of typing long commands, tasks can now be performed in a single click Ansible Tower
  • 66.
    Use case byHootsuite
  • 67.
    Hootsuite is asocial media management system Use case by Hootsuite
  • 68.
    They assist businessesin campaigning across social media platforms Use case by Hootsuite
  • 69.
    But as theygained popularity, a crisis struck Use case by Hootsuite
  • 70.
    Servers had tobe rebuilt continuously Use case by Hootsuite
  • 71.
    Unfortunately, there wasno standard documentation and the entire process relied on memory Use case by Hootsuite
  • 72.
    This is whenthe need for Ansible was realised Use case by Hootsuite
  • 73.
    Now, playbooks arewritten to deploy servers providing a standardization Use case by Hootsuite
  • 74.
    Servers are builtand rebuilt in a matter of seconds Use case by Hootsuite
  • 75.
    Use case byHootsuite Servers are built and rebuilt in a matter of seconds
  • 76.
    Key Takeaways Ansible- pullconfiguration tool Ansible architecture What is ansible?Why ansible? playbook Inventory
  • 77.
    Key Takeaways Ansible towerWorkingof ansible Use case by hootsuite

Editor's Notes