SlideShare a Scribd company logo
1 of 15
Ansible Configuration
management
Afroz Hussain
Agenda
 What is Ansible?
 How is it different?
 how does it work?
 Installation
 The ansible tools
 Running some adhoc commands
 What is Playbooks?
 Basic playbook
 Handlers
 Roles
 Demo: Playbook for Apache
What is Ansible?
 Ansible is a radically simple IT automation engine that automates cloud
provisioning, configuration management, application deployment, intra-
service orchestration Ansible’s goals are foremost those of simplicity and
maximum ease of use.
 Ansible manages machines in an agentless manner.
 There is never a question of how to upgrade remote daemons or the problem
of not being able to manage systems because daemons are uninstalled.
 It uses a very simple language (YAML, in the form of Ansible Playbooks) that
allow you to describe your automation jobs in a way that approaches plain
English.
How is it different?
 Agent-less architecture
 Configuration as data, not code
 Betterires-included(module).
 Full configuration management, orechestration, deployment.
How does it work?
Installation
 Installation RHEL/CentOS/Fedora
 1. Enable EPL on RedHat
 ## RHEL/CentOS 6 64-Bit ##
 # rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
 # yum repolist # verify the EPL Repo
 2. Install ansible
 #yum install ansible -y
 # ansible --version # verify the ansible installation
 3. Preparing ssh keys to connect to remote hosts
# ssh-keygen -t rsa -b 4096
 4. Agent setup
 cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
 Note : Please make sure .ssh has 700 and authorized_keys has 400 permission
 Ansible comes with several command-line tools. The first one is simply
called… ansible.
 The purpose of the ansible tool is mainly to execute a command over selected
groups of an inventory.
 Creating Inventory file for remote hosts:
 vim /etc/ansible/hosts
The ansible tool:
Installation
Running some commands:
 Verify all the remote hosts are getting pinged from our ansible server using
ping module(-m ping)
 ansible -m ping 10.20.30.40
 ansible -m ping all
 ansible -m ping web-servers
 ansible -m command -a "df -h" 10.20.30.40
 File Management:
 ansible web-servers -m copy -a "src=/etc/hosts dest=/tmp/hosts"
 ansible web-servers -m file -a "dest=/srv/foo/a.txt mode=600"
 ansible web-servers -m file -a "dest=/srv/foo/b.txt mode=600 owner=afroz
group=afroz
Running some commands(contd..)
 Package management
 ansible web-servers -m yum -a "name=httpd state=present"
 ansible web-servers -m yum -a "name=httpd state=latest"
 User and Group
 ansible all -m user -a "name=hssain upassword=hussain"
 ansible all -m user -a "name=hussain state=absent"
 Managing Services:
 ansible web-servers -m service -a "name=httpd state=started"
 ansible web-servers -m service -a "name=httpd state=restarted"
 ansible web-servers -m service -a "name=httpd state=stopped“
 Gathering the facts(node info)
 ansible all -m setup
Playbooks
 Playbooks are Ansible’s configuration, deployment, and orchestration
language.
 They can describe a policy you want your remote systems to enforce, or a set
of steps in a general IT process.
 It runs multiple Tasks and provide some more advanced functionality that we
would miss out on using ad-hoc commands.
 Playboooks contains plays.
 plays contains tasks
 tasks contains modules
 Modules: The actual work done by modules such
file,yum,host,service,ping,command etc.
Basic Playbook
 Playbooks and Roles in Ansible all use Yaml.
Handlers
 A Handler is exactly the same as a Task (it can do anything a Task can), but it
will run when called by another Task.
 We can think of it as part of an Event system; A Handler will take an action
when called by an event it listens for.
Roles
 Roles are good for organizing multiple, related Tasks and encapsulating data
needed to accomplish those Tasks.
 The configuration portion often requires extra data such as variables, files,
dynamic templates and more.
 Roles have a directory structure like this:
Demo: Playbook for Apache
Thank You

More Related Content

What's hot

Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Simplilearn
 
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
 
Red hat ansible automation technical deck
Red hat ansible automation technical deckRed hat ansible automation technical deck
Red hat ansible automation technical deck
Juraj Hantak
 

What's hot (20)

Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
 
Automating with Ansible
Automating with AnsibleAutomating with Ansible
Automating with Ansible
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Ansible
AnsibleAnsible
Ansible
 
ansible why ?
ansible why ?ansible why ?
ansible why ?
 
DevOps with Ansible
DevOps with AnsibleDevOps with Ansible
DevOps with Ansible
 
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
 
Best practices for ansible
Best practices for ansibleBest practices for ansible
Best practices for ansible
 
Ansible
AnsibleAnsible
Ansible
 
Network Automation with Ansible
Network Automation with AnsibleNetwork Automation with Ansible
Network Automation with Ansible
 
Ansible 101
Ansible 101Ansible 101
Ansible 101
 
Avaya VoIP on Cisco Best Practices by PacketBase
Avaya VoIP on Cisco Best Practices by PacketBaseAvaya VoIP on Cisco Best Practices by PacketBase
Avaya VoIP on Cisco Best Practices by PacketBase
 
Red Hat Ansible 적용 사례
Red Hat Ansible 적용 사례Red Hat Ansible 적용 사례
Red Hat 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...
 
Ansible Automation - Enterprise Use Cases | Juncheng Anthony Lin
Ansible Automation - Enterprise Use Cases | Juncheng Anthony LinAnsible Automation - Enterprise Use Cases | Juncheng Anthony Lin
Ansible Automation - Enterprise Use Cases | Juncheng Anthony Lin
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
 
Ansible Automation Platform.pdf
Ansible Automation Platform.pdfAnsible Automation Platform.pdf
Ansible Automation Platform.pdf
 
Red hat ansible automation technical deck
Red hat ansible automation technical deckRed hat ansible automation technical deck
Red hat ansible automation technical deck
 

Similar to Ansible

Ansible automation tool with modules
Ansible automation tool with modulesAnsible automation tool with modules
Ansible automation tool with modules
mohamedmoharam
 

Similar to Ansible (20)

Ansible_Basics_ppt.pdf
Ansible_Basics_ppt.pdfAnsible_Basics_ppt.pdf
Ansible_Basics_ppt.pdf
 
Ansible automation tool with modules
Ansible automation tool with modulesAnsible automation tool with modules
Ansible automation tool with modules
 
Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdf
 
Hands On Introduction To Ansible Configuration Management With Ansible Comple...
Hands On Introduction To Ansible Configuration Management With Ansible Comple...Hands On Introduction To Ansible Configuration Management With Ansible Comple...
Hands On Introduction To Ansible Configuration Management With Ansible Comple...
 
Basics of Ansible - Sahil Davawala
Basics of Ansible - Sahil DavawalaBasics of Ansible - Sahil Davawala
Basics of Ansible - Sahil Davawala
 
DevOps for database
DevOps for databaseDevOps for database
DevOps for database
 
Ansible a tool for dev ops
Ansible a tool for dev opsAnsible a tool for dev ops
Ansible a tool for dev ops
 
Top 50 Ansible Interview Questions And Answers in 2023.pdf
Top 50 Ansible Interview Questions And Answers in 2023.pdfTop 50 Ansible Interview Questions And Answers in 2023.pdf
Top 50 Ansible Interview Questions And Answers in 2023.pdf
 
UNIT-I Introduction to Ansible.pptx
UNIT-I Introduction to Ansible.pptxUNIT-I Introduction to Ansible.pptx
UNIT-I Introduction to Ansible.pptx
 
Ansible Playbook
Ansible PlaybookAnsible Playbook
Ansible Playbook
 
iac.pptx
iac.pptxiac.pptx
iac.pptx
 
Ansible Hands On
Ansible Hands OnAnsible Hands On
Ansible Hands On
 
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
 
Ansible & Salt - Vincent Boon
Ansible & Salt - Vincent BoonAnsible & Salt - Vincent Boon
Ansible & Salt - Vincent Boon
 
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)
 
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_rhel.pdf
ansible_rhel.pdfansible_rhel.pdf
ansible_rhel.pdf
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy System
 
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Ansible 2.0 - How to use Ansible to automate your applications in AWS.Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
 
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Ansible 2.0 - How to use Ansible to automate your applications in AWS.Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
 

Ansible

  • 2. Agenda  What is Ansible?  How is it different?  how does it work?  Installation  The ansible tools  Running some adhoc commands  What is Playbooks?  Basic playbook  Handlers  Roles  Demo: Playbook for Apache
  • 3. What is Ansible?  Ansible is a radically simple IT automation engine that automates cloud provisioning, configuration management, application deployment, intra- service orchestration Ansible’s goals are foremost those of simplicity and maximum ease of use.  Ansible manages machines in an agentless manner.  There is never a question of how to upgrade remote daemons or the problem of not being able to manage systems because daemons are uninstalled.  It uses a very simple language (YAML, in the form of Ansible Playbooks) that allow you to describe your automation jobs in a way that approaches plain English.
  • 4. How is it different?  Agent-less architecture  Configuration as data, not code  Betterires-included(module).  Full configuration management, orechestration, deployment.
  • 5. How does it work?
  • 6. Installation  Installation RHEL/CentOS/Fedora  1. Enable EPL on RedHat  ## RHEL/CentOS 6 64-Bit ##  # rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm  # yum repolist # verify the EPL Repo  2. Install ansible  #yum install ansible -y  # ansible --version # verify the ansible installation  3. Preparing ssh keys to connect to remote hosts # ssh-keygen -t rsa -b 4096  4. Agent setup  cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys  Note : Please make sure .ssh has 700 and authorized_keys has 400 permission
  • 7.  Ansible comes with several command-line tools. The first one is simply called… ansible.  The purpose of the ansible tool is mainly to execute a command over selected groups of an inventory.  Creating Inventory file for remote hosts:  vim /etc/ansible/hosts The ansible tool: Installation
  • 8. Running some commands:  Verify all the remote hosts are getting pinged from our ansible server using ping module(-m ping)  ansible -m ping 10.20.30.40  ansible -m ping all  ansible -m ping web-servers  ansible -m command -a "df -h" 10.20.30.40  File Management:  ansible web-servers -m copy -a "src=/etc/hosts dest=/tmp/hosts"  ansible web-servers -m file -a "dest=/srv/foo/a.txt mode=600"  ansible web-servers -m file -a "dest=/srv/foo/b.txt mode=600 owner=afroz group=afroz
  • 9. Running some commands(contd..)  Package management  ansible web-servers -m yum -a "name=httpd state=present"  ansible web-servers -m yum -a "name=httpd state=latest"  User and Group  ansible all -m user -a "name=hssain upassword=hussain"  ansible all -m user -a "name=hussain state=absent"  Managing Services:  ansible web-servers -m service -a "name=httpd state=started"  ansible web-servers -m service -a "name=httpd state=restarted"  ansible web-servers -m service -a "name=httpd state=stopped“  Gathering the facts(node info)  ansible all -m setup
  • 10. Playbooks  Playbooks are Ansible’s configuration, deployment, and orchestration language.  They can describe a policy you want your remote systems to enforce, or a set of steps in a general IT process.  It runs multiple Tasks and provide some more advanced functionality that we would miss out on using ad-hoc commands.  Playboooks contains plays.  plays contains tasks  tasks contains modules  Modules: The actual work done by modules such file,yum,host,service,ping,command etc.
  • 11. Basic Playbook  Playbooks and Roles in Ansible all use Yaml.
  • 12. Handlers  A Handler is exactly the same as a Task (it can do anything a Task can), but it will run when called by another Task.  We can think of it as part of an Event system; A Handler will take an action when called by an event it listens for.
  • 13. Roles  Roles are good for organizing multiple, related Tasks and encapsulating data needed to accomplish those Tasks.  The configuration portion often requires extra data such as variables, files, dynamic templates and more.  Roles have a directory structure like this: