SlideShare a Scribd company logo
Basics of Ansible - Sahil Davawala
 DevOps - a clipped compound of "development" and "operations"
 Automate the software integration, testing, deployment, and infrastructure
changes.
 Improve automation and measurement of system metrics.
 The best powerful automation tool which can help us in achieving everything is
ANSIBLE.
Basics of Ansible - Sahil Davawala
 Basics of Ansible
 Usage of Ansible
 Ansible without playbook i.e. through Adhoc commands
 Ansible with playbook
 Ansible modules
 Installation of a package on multiple instances followed by a Demo.
It is an IT automation tool which can configure systems, deploy
software, and orchestrate more advanced IT tasks such as
continuous deployments or zero downtime rolling updates.
 Ansible is an agent-less and uses a PUSH(SSH) approach.
 It is developed by RedHat.
 It is an OpenSource application.
 Platforms supported are Linux & Windows.
 Linux for control machine & Windows for managed nodes.
 Latest version of ansible is 2.3
Reference URL : https://github.com/ansible/ansible/releases
 Major companies using Ansible are Atlassian, CISCO, EA Sports, NASA, RedHat,
Twitter and many more.
Control Machine Requirements
 Currently Ansible can be run from any machine with Python 2.6 or 2.7 installed
Managed Node Requirements(Target Host)
 On the managed nodes, you need a way to communicate, which is normally SSH.
You also need Python 2.6 or later installed for the same.
Basics of Ansible - Sahil Davawala
Chef/Puppet Ansible
• Needs to be installed on Agents.
• Agents pull changes from a master.
• Communication channel used is their own
(usually not SSH)
• Complicated
setup/architecture/installation
• Complicated orchestration.
• Chef uses Ruby in backend and pure Ruby
DSL for configuration.
• Puppet using Ruby in backend and uses
Puppet DSL for configuration.
• Need not be installed on Agents.
• Pushes the changes to Agents whenever
required.
• Uses SSH
• Easy installation and architecture
• Simplified orchestration.
• Ansible backed is on Python.
• Uses YAML as configuration files.
 Installing Ansible on CentOS :
 To get Ansible for CentOS 7, first ensure that the CentOS 7 EPEL repository is
installed:
sudo yum install epel-release
sudo yum update
 Once the repository is installed, install Ansible with yum:
sudo yum install ansible
 Installing Ansible on Ubuntu :
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible
 Run command : ansible –version
 Example output :
ansible 2.3.1.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
NOTE : If anyone wants to execute the playbook on a remote machine
then it is mandatory to have Python libraries installed on that remote machine.
 Certain settings in Ansible are adjustable via a configuration file. This
configuration file is know as ANSIBLE CONFIG
 Ansible allows configuration of settings via environment variables. If these
environment variables are set, they will override any setting loaded from the
configuration file.
 Here is the order in which configuration file will be processed.
 We use YAML because it is easier for humans to read and write than other common data formats like XML or JSON.
 All YAML files (regardless of their association with Ansible or not) can optionally begin with --- and end with ... This is part of the YAML
format and indicates the start and end of a document.
 All members of a list are lines beginning at the same indentation level starting with a "- " (a dash and a space):
Example :
---
# A list of tasty fruits
fruits:
- Apple
- Orange
- Strawberry
- Mango
…
 A dictionary is represented in a simple key: value form (the colon must be followed by a space):
Example :
# An employee record
martin:
name: Martin D'vloper
job: Developer
skill: Elite
Basics of Ansible - Sahil Davawala
 Ansible works against multiple systems in our infrastructure at a particular point
of time.
 It does this by selecting portions of systems listed in Ansible’s inventory which
defaults to being saved at the location : /etc/ansible/hosts.
 You can specify a different inventory file using the -i <path> option on the
command line
 Example : ansible-playbook -i playbook.yml
 It can be used in both commands & playbooks.
 Types of inventories includes basic list, shell script, python script, advanced script
like ec2,etc.
Basics of Ansible - Sahil Davawala
 To ping multiple servers at a time(which are existing in inventory file) :
 ansible –m ping all
 For creating a new user and manipulation of existing user accounts :
 ansible all -m user -a "name=foo password=<crypted password here>”
 Ensure a service is started on all webservers:
 ansible webservers -m service -a "name=httpd state=started"
 Ansible adhoc commands have the limitation in complex scenarios so to overcome
this and make the automation easy & robust, playbooks were introduced.
 Playbooks can be used to manage configurations and deployments to remote
machines.
 Here is the example how to use a playbook.
 ansible-playbook first.yml –e name=webservers1
Basics of Ansible - Sahil Davawala
 apt module
 yum module
 package module
 shell module
 command module
 user module
 hostname module
 The apt module manages the apt packages.
Example :
- name: Remove "foo" package.
apt:
name: foo
state: absent
- name: Install the package "foo"
apt:
name: foo
state: present
 Installs, upgrade, removes, and lists packages and groups with the yum package
manager.
Example :
- name: install the latest version of Apache
yum:
name: httpd
state: latest
 Installs, upgrade and removes packages using the underlying OS package
manager.
Example :
- name: install the latest version of ntpdate
package:
name: ntpdate
state: latest
 The shell module takes the command name followed by a list of space-delimited
arguments. It is almost exactly like the command module but runs the command
through a shell (/bin/sh) on the remote node.
Example :
- name: Executing a Command Using Shell Module
shell: ls -lrt > temp.txt
The above command lists all the files in the current folder and writes that to the file i.e.
temp.txt.
 The command module takes the command name followed by a list of space-
delimited arguments.
 The given command will be executed on all selected nodes. It will not be processed
through the shell, so variables like $HOME and operations
like "<", ">", "|", ";" and "&" will not work.
Example :
- name: Executing a command using command module.
command: cat hello.txt
The above command displays the content of the file hello.txt
 Manage user accounts and user attributes.
Example :
- user:
name: johnd
comment: "John Doe"
uid: 1040
group: admin
 Set system’s hostname, supports most OSs/Distributions, including those using
systemd.
 Note, this module does NOT modify /etc/hosts. You need to modify it yourself using
other modules like template or replace.
Example :
- hostname:
name: web01
Basics of Ansible - Sahil Davawala
 Ansible command using a direct agent.
 Ansible command using an Inventory group.
 Ansible playbook for direct host (agent)
 Ansible playbook split into multiple tasks.
 Ansible playbook installing a service on multiple hosts.
Basics of Ansible - Sahil Davawala

More Related Content

What's hot (19)

PPTX
Go Faster with Ansible (AWS meetup)
Richard Donkin
 
PDF
IT Automation with Ansible
Rayed Alrashed
 
PDF
Ansible is the simplest way to automate. MoldCamp, 2015
Alex S
 
PDF
#OktoCampus - Workshop : An introduction to Ansible
Cédric Delgehier
 
PDF
Ansible best practices
StephaneFlotat1
 
PDF
Infrastructure = Code
Georg Sorst
 
PDF
Ansible 101
Gena Mykhailiuta
 
ODP
Ansible basics workshop
David Karban
 
PDF
Ansible Introduction - Ansible Brno #1 - David Karban
ansiblebrno
 
PDF
Managing Your Cisco Datacenter Network with Ansible
fmaccioni
 
PDF
Ansible container
Scott van Kalken
 
PDF
Ansible - Swiss Army Knife Orchestration
bcoca
 
PDF
Ansible + WordPress - WordCamp Toronto 2016
Alan Lok
 
PDF
Ansible testing
Scott van Kalken
 
PPTX
Ansible intro
Hsi-Kai Wang
 
PDF
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
Jumping Bean
 
PDF
20명 규모의 팀에서 Vault 사용하기
Doyoon Kim
 
PPTX
Introduction to ansible
Dharmit Shah
 
PPTX
Breaking Up With Your Data Center Presentation
Telescope_Inc
 
Go Faster with Ansible (AWS meetup)
Richard Donkin
 
IT Automation with Ansible
Rayed Alrashed
 
Ansible is the simplest way to automate. MoldCamp, 2015
Alex S
 
#OktoCampus - Workshop : An introduction to Ansible
Cédric Delgehier
 
Ansible best practices
StephaneFlotat1
 
Infrastructure = Code
Georg Sorst
 
Ansible 101
Gena Mykhailiuta
 
Ansible basics workshop
David Karban
 
Ansible Introduction - Ansible Brno #1 - David Karban
ansiblebrno
 
Managing Your Cisco Datacenter Network with Ansible
fmaccioni
 
Ansible container
Scott van Kalken
 
Ansible - Swiss Army Knife Orchestration
bcoca
 
Ansible + WordPress - WordCamp Toronto 2016
Alan Lok
 
Ansible testing
Scott van Kalken
 
Ansible intro
Hsi-Kai Wang
 
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
Jumping Bean
 
20명 규모의 팀에서 Vault 사용하기
Doyoon Kim
 
Introduction to ansible
Dharmit Shah
 
Breaking Up With Your Data Center Presentation
Telescope_Inc
 

Similar to Basics of Ansible - Sahil Davawala (20)

PPTX
Ansible as configuration management tool for devops
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
PDF
Ansible_Basics_ppt.pdf
PrabhjotSingh976002
 
PPTX
UNIT-I Introduction to Ansible.pptx
Pandiya Rajan
 
PDF
Automate with Ansible basic (2/e, English)
Chu-Siang Lai
 
PPTX
SESSION Ansible how to deploy and push resources
Saravanan68713
 
PDF
Automation with ansible
Khizer Naeem
 
PDF
Managing MySQL with Ansible
Ben Mildren
 
PDF
Ansible101
Hideki Saito
 
PPTX
Ansible Network Automation session1
Dhruv Sharma
 
PPTX
Intro to-ansible-sep7-meetup
Ramesh Godishela
 
PDF
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Idan Tohami
 
PDF
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Idan Tohami
 
PPTX
Automating with ansible (Part A)
iman darabi
 
PPTX
Ansible: What, Why & How
Alfonso Cabrera
 
PDF
Automated Deployment and Configuration Engines. Ansible
Alberto Molina Coballes
 
PPTX
Ansible
Afroz Hussain
 
PDF
A tour of Ansible
DevOps Ltd.
 
PDF
Automating with ansible (part a)
iman darabi
 
PDF
Configuration Management in Ansible
Bangladesh Network Operators Group
 
Ansible as configuration management tool for devops
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Ansible_Basics_ppt.pdf
PrabhjotSingh976002
 
UNIT-I Introduction to Ansible.pptx
Pandiya Rajan
 
Automate with Ansible basic (2/e, English)
Chu-Siang Lai
 
SESSION Ansible how to deploy and push resources
Saravanan68713
 
Automation with ansible
Khizer Naeem
 
Managing MySQL with Ansible
Ben Mildren
 
Ansible101
Hideki Saito
 
Ansible Network Automation session1
Dhruv Sharma
 
Intro to-ansible-sep7-meetup
Ramesh Godishela
 
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Idan Tohami
 
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Idan Tohami
 
Automating with ansible (Part A)
iman darabi
 
Ansible: What, Why & How
Alfonso Cabrera
 
Automated Deployment and Configuration Engines. Ansible
Alberto Molina Coballes
 
Ansible
Afroz Hussain
 
A tour of Ansible
DevOps Ltd.
 
Automating with ansible (part a)
iman darabi
 
Configuration Management in Ansible
Bangladesh Network Operators Group
 
Ad

Recently uploaded (20)

PPTX
Employee salary prediction using Machine learning Project template.ppt
bhanuk27082004
 
PDF
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
PDF
Step-by-Step Guide to Install SAP HANA Studio | Complete Installation Tutoria...
SAP Vista, an A L T Z E N Company
 
PDF
How to Download and Install ADT (ABAP Development Tools) for Eclipse IDE | SA...
SAP Vista, an A L T Z E N Company
 
PPT
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
PPT
Brief History of Python by Learning Python in three hours
adanechb21
 
PPT
Activate_Methodology_Summary presentatio
annapureddyn
 
PPTX
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PDF
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
PDF
AWS_Agentic_AI_in_Indian_BFSI_A_Strategic_Blueprint_for_Customer.pdf
siddharthnetsavvies
 
PDF
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
PDF
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
PPTX
Farrell__10e_ch04_PowerPoint.pptx Programming Logic and Design slides
bashnahara11
 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
PDF
Troubleshooting Virtual Threads in Java!
Tier1 app
 
PPTX
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
PDF
What companies do with Pharo (ESUG 2025)
ESUG
 
Employee salary prediction using Machine learning Project template.ppt
bhanuk27082004
 
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
Step-by-Step Guide to Install SAP HANA Studio | Complete Installation Tutoria...
SAP Vista, an A L T Z E N Company
 
How to Download and Install ADT (ABAP Development Tools) for Eclipse IDE | SA...
SAP Vista, an A L T Z E N Company
 
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
Brief History of Python by Learning Python in three hours
adanechb21
 
Activate_Methodology_Summary presentatio
annapureddyn
 
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
AWS_Agentic_AI_in_Indian_BFSI_A_Strategic_Blueprint_for_Customer.pdf
siddharthnetsavvies
 
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
Farrell__10e_ch04_PowerPoint.pptx Programming Logic and Design slides
bashnahara11
 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
Troubleshooting Virtual Threads in Java!
Tier1 app
 
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
What companies do with Pharo (ESUG 2025)
ESUG
 
Ad

Basics of Ansible - Sahil Davawala

  • 2.  DevOps - a clipped compound of "development" and "operations"  Automate the software integration, testing, deployment, and infrastructure changes.  Improve automation and measurement of system metrics.  The best powerful automation tool which can help us in achieving everything is ANSIBLE.
  • 4.  Basics of Ansible  Usage of Ansible  Ansible without playbook i.e. through Adhoc commands  Ansible with playbook  Ansible modules  Installation of a package on multiple instances followed by a Demo.
  • 5. It is an IT automation tool which can configure systems, deploy software, and orchestrate more advanced IT tasks such as continuous deployments or zero downtime rolling updates.
  • 6.  Ansible is an agent-less and uses a PUSH(SSH) approach.  It is developed by RedHat.  It is an OpenSource application.  Platforms supported are Linux & Windows.  Linux for control machine & Windows for managed nodes.  Latest version of ansible is 2.3 Reference URL : https://github.com/ansible/ansible/releases  Major companies using Ansible are Atlassian, CISCO, EA Sports, NASA, RedHat, Twitter and many more.
  • 7. Control Machine Requirements  Currently Ansible can be run from any machine with Python 2.6 or 2.7 installed Managed Node Requirements(Target Host)  On the managed nodes, you need a way to communicate, which is normally SSH. You also need Python 2.6 or later installed for the same.
  • 9. Chef/Puppet Ansible • Needs to be installed on Agents. • Agents pull changes from a master. • Communication channel used is their own (usually not SSH) • Complicated setup/architecture/installation • Complicated orchestration. • Chef uses Ruby in backend and pure Ruby DSL for configuration. • Puppet using Ruby in backend and uses Puppet DSL for configuration. • Need not be installed on Agents. • Pushes the changes to Agents whenever required. • Uses SSH • Easy installation and architecture • Simplified orchestration. • Ansible backed is on Python. • Uses YAML as configuration files.
  • 10.  Installing Ansible on CentOS :  To get Ansible for CentOS 7, first ensure that the CentOS 7 EPEL repository is installed: sudo yum install epel-release sudo yum update  Once the repository is installed, install Ansible with yum: sudo yum install ansible  Installing Ansible on Ubuntu : sudo apt-get install software-properties-common sudo apt-add-repository ppa:ansible/ansible sudo apt-get update sudo apt-get install ansible
  • 11.  Run command : ansible –version  Example output : ansible 2.3.1.0 config file = /etc/ansible/ansible.cfg configured module search path = Default w/o overrides NOTE : If anyone wants to execute the playbook on a remote machine then it is mandatory to have Python libraries installed on that remote machine.
  • 12.  Certain settings in Ansible are adjustable via a configuration file. This configuration file is know as ANSIBLE CONFIG  Ansible allows configuration of settings via environment variables. If these environment variables are set, they will override any setting loaded from the configuration file.  Here is the order in which configuration file will be processed.
  • 13.  We use YAML because it is easier for humans to read and write than other common data formats like XML or JSON.  All YAML files (regardless of their association with Ansible or not) can optionally begin with --- and end with ... This is part of the YAML format and indicates the start and end of a document.  All members of a list are lines beginning at the same indentation level starting with a "- " (a dash and a space): Example : --- # A list of tasty fruits fruits: - Apple - Orange - Strawberry - Mango …  A dictionary is represented in a simple key: value form (the colon must be followed by a space): Example : # An employee record martin: name: Martin D'vloper job: Developer skill: Elite
  • 15.  Ansible works against multiple systems in our infrastructure at a particular point of time.  It does this by selecting portions of systems listed in Ansible’s inventory which defaults to being saved at the location : /etc/ansible/hosts.  You can specify a different inventory file using the -i <path> option on the command line  Example : ansible-playbook -i playbook.yml  It can be used in both commands & playbooks.  Types of inventories includes basic list, shell script, python script, advanced script like ec2,etc.
  • 17.  To ping multiple servers at a time(which are existing in inventory file) :  ansible –m ping all  For creating a new user and manipulation of existing user accounts :  ansible all -m user -a "name=foo password=<crypted password here>”  Ensure a service is started on all webservers:  ansible webservers -m service -a "name=httpd state=started"
  • 18.  Ansible adhoc commands have the limitation in complex scenarios so to overcome this and make the automation easy & robust, playbooks were introduced.  Playbooks can be used to manage configurations and deployments to remote machines.  Here is the example how to use a playbook.  ansible-playbook first.yml –e name=webservers1
  • 20.  apt module  yum module  package module  shell module  command module  user module  hostname module
  • 21.  The apt module manages the apt packages. Example : - name: Remove "foo" package. apt: name: foo state: absent - name: Install the package "foo" apt: name: foo state: present
  • 22.  Installs, upgrade, removes, and lists packages and groups with the yum package manager. Example : - name: install the latest version of Apache yum: name: httpd state: latest
  • 23.  Installs, upgrade and removes packages using the underlying OS package manager. Example : - name: install the latest version of ntpdate package: name: ntpdate state: latest
  • 24.  The shell module takes the command name followed by a list of space-delimited arguments. It is almost exactly like the command module but runs the command through a shell (/bin/sh) on the remote node. Example : - name: Executing a Command Using Shell Module shell: ls -lrt > temp.txt The above command lists all the files in the current folder and writes that to the file i.e. temp.txt.
  • 25.  The command module takes the command name followed by a list of space- delimited arguments.  The given command will be executed on all selected nodes. It will not be processed through the shell, so variables like $HOME and operations like "<", ">", "|", ";" and "&" will not work. Example : - name: Executing a command using command module. command: cat hello.txt The above command displays the content of the file hello.txt
  • 26.  Manage user accounts and user attributes. Example : - user: name: johnd comment: "John Doe" uid: 1040 group: admin
  • 27.  Set system’s hostname, supports most OSs/Distributions, including those using systemd.  Note, this module does NOT modify /etc/hosts. You need to modify it yourself using other modules like template or replace. Example : - hostname: name: web01
  • 29.  Ansible command using a direct agent.  Ansible command using an Inventory group.  Ansible playbook for direct host (agent)  Ansible playbook split into multiple tasks.  Ansible playbook installing a service on multiple hosts.

Editor's Notes

  • #3: DevOps (a clipped compound of "development" and "operations") is a software development and delivery process that emphasizes communication and collaboration between product management, software development, and operations professionals.  It seeks to automate the process of software integration, testing, deployment, and infrastructure changes by establishing a culture and environment where building, testing, and releasing software can happen rapidly, frequently, and more reliably.
  • #7: And ofcourse Crest Data Systems is one of the major companies.
  • #8: For Windows : Need pywinrm on control machine(Linux) Need PowerShell on the target machine(Windows)
  • #9: Change Management - Provisioning - Automation - Orchestration - It basically means the automated arrangement, coordination, and management of complex computer systems, and services.
  • #10: https://www.ansible.com/blog/orchestration-you-keep-using-that-word
  • #19: Playbooks - Playbooks are Ansible’s configuration, deployment, and orchestration language. Playbooks are designed to be human-readable and are developed in a basic text language.
  • #21: And many more…. Ansible is famous because of N number of modules support they provide.
  • #24: RPM family(Linux,CentOS) : Httpd Debian family(Ubuntu) : Apache Reference URL(using package module on multiple OS) : https://serverfault.com/questions/587727/how-to-unify-package-installation-tasks-in-ansible
  • #30: Commands : ansible -m ping all ansible-playbook first.yml -e name=webservers1