Free Shipping

Secure Payment

easy returns

24/7 support

What is Ansible?

 June 17  | 0 Comments

In this post, we will discuss a brief overview of how industries are using Ansible for Configuration management, what is it’s a need and working.

What You Will Learn

  • What is Ansible?
  • Configuration Management
  • Push Based VS Pull Based
  • How To Install Ansible
  • Host Inventory
  • Ansible Modules
  • Understanding YAML
  • Ansible Playbook

Now let’s get started with our first topic, So let’s begin

What is ansible?

Ansible is a simple open-source IT engine that automates application development, intra service orchestration, cloud provisioning, and many other IT  tools.

Ansible also is very easy to deploy because it does not use any agent or customer security infrastructures.

Ansible uses Ansible playbooks to describe automation jobs and playbook uses very simple language that is the YAML.

What is YAML?

YAML is a human-readable data serialization language which is commonly used to build configuration files and in applications where data is being stored or transmitted.

The advantage of the YAML file is that even the IT infrastructure support professionals can read and understand the playbook and debug if needed easily.

So ansible is completely agentless which means ansible works by connecting the nodes to ssh by default but if you want any another method for connection like Kerberos ansible also gives you that option.

After connecting to the nodes ansible pushes some small programs called ansible modules ansible runs that modules on nodes and remove them when the work is finished. It also manages your inventory with the simple text file that basically hosts files that you can see below.

Ansible uses the host file where one can group the hosts and control the action on a specified group in the playbooks.

As you know ansible is a control management tool you should also understand configuration management before you understand how to deploy it with the tools.

What Is Configuration Management?

Configuration management in terms of ansible means that it maintains the configuration of product performance by keeping a record and updating detailed information which describes and enterprise hardware and such a piece of information includes the exact versions and updates that apply to install packages and the locations and network addresses of devices.

For example, if you want to install a new version of a web logic server on all the machines present on the in your enterprise it is not feasible for you to manually go and update each and every machine.

So you can install the web logic server in one go on all your machines with the ansible-playbook.

All you have to do is list out all IP addresses of your nodes in the inventory and write a playbook to install the web logic server after that you have to run the playbook from your control machine and then it will be installed on all your nodes.

How Ansible Works?

Basically ansible works by connecting nodes and pushing outs small programs called ansible modules to when ansible executes these modules over ssh by default and then removes them when finished.

So your library of modules resides on any one machine and there are node servers daemons databases required.

As you can see below picture is basically controlling the node which controls the entire execution of the playbook.

It’s the node from which you are running the installation and the inventory file provides the hosts where ansible module needs to be run.

And then management node does the ssh connection to other nodes listed in the inventory and then it executes the ansible modules on the host machines and installs the product.

So this is how Ansible works.

Features Of Ansible


The first feature is agentless which means there is no kind of software any kind of agent that managing your node unlike puppet or puppet or chef you need to install the puppet agent or chef-client on all your nodes.

But for the ansible, you just have to install ansible in your control machine and then you are good to go.

Build on python

It is built on top of python and this helps to provide a lot of functionality of python.


Ansible uses ssh for secure connection now, ssh is very simple to password less network authentication protocol which is very secure.

So your responsibility just generates a public key on your control machine and copy the same key on your node machines.

Push based Architecture

Ansible is pushing base application for sending configurations, in the case of ansible where you want to make kind of configuration changes on your nodes all you have to do is write down the configuration and then you just have to push them all at once on your nodes.

When we talk in simple terms what it does is that it gives full control over whenever you want to make changes on your node and also makes it very easy and fast to set up and need very minimal requirements.

As we say ansible is a push-based application what do you think what is the difference between push-based application and pull-based application?

Well, tools like puppet and chef are basically pull-based applications and whereas ansible is a push-based application for configuration management.

Now in the case of puppet and chef, you can present the agent software that puppet has and is basically called the puppet agent and in case of the chef, it is known as chef-client. So what exactly agent does is that it keeps pulling on the central server periodically for any kind of configuration information.

And whatever information agent finds it pulls those changes and then gets them affected on your node machines.

Whereas in the case of Ansible since there are no agents present whenever you want to make any changes you can make those changes directly and you can push those configurations directly whenever you want to as you got full control over it.

Example of push-based application architecture and pull-based application architecture you can see in the below picture.

How To Install Ansible On Ubuntu?

Before we start the installation let me tell you that there are basically two types of  machines for the deployment of ansible those are the control machine and the remote machine

So the control machines are machines from where we can manage other machines and the remote machine is those machines which are handle or control by the control machines.

So there can be multiple remote machines which are handled by a single control machine in order to handle remote machines we have to install ansible on the control machine.

Let’s get started with the installation

Step 1: Update the repositories using the below command.

sudo apt-get update

Step 2: Install the common software properties by using the below command.

sudo apt-get install software-properties-common -y

Step 3: Add Ansible repositories using the below command.

sudo apt-add-repository ppa:ansible/ansible -y

Step 4: Update the repositories using the below command.

sudo apt-get update -y

Step 5: Install the Ansible tool using the below command.

sudo apt-get install ansible -y

We have done with the installation of ansible on ubuntu here.

Let’s move to our next topic which is

Host Inventory

Inventory defines a group of hosts for example you can group web servers in one group and application server in one group. So the group can have multiple servers and a single server that can be a part of multiple groups.

If you want to group my web servers together and my data servers together all you have to do is just write a group name between the two square brackets [ ].

If you want to make some configuration changes on the webserver but not on data servers then you just have to specify the group name on the host then it will automatically configure your web server.

Ansible Modules

Modules are nothing but the executables plugins that get the real job done. usually, modules can take the key-value argument and runs in a customized way depending on the argument given.

So the module can be invoked by the command line or its included in the ansible-playbook.

Commands related to the Ansible Module:

  1. If you want to use modules from the command lines you have to type the below command.
ansible all -m ping
  • If you want to use the ping mode to ping all the host find in the inventory then you have to type the below command
ansible webservers -m command -a “ls”
  • If you want to flush IP tables rule on all the hosts available in inventory then you have to type the below command.
ansible -i inventory all -m command -a “iptables-F” --become --ask-become-pass
  • If you want to gather facts about the ansible then you have to type the below command.
ansible all -m setup
  • If you want to extract particular facts in the documentation of the setup module you have to type the below command.
ansible-doc setup

Understanding YAML

Ansible uses YAML f syntax for expressing ansible-playbook because it’s really simple to understand, read and write compared to other data formats like XML and JSON.

Every YAML file starts with three “—” and ends with three dots “…”. You can also use Abbreviations in YAML to represent dictionaries.

Not only this but we can also represent the list in the YAML file.

Ansible Playbook

Playbooks are the files where ansible code is written and these are written in YAML format so YAML stands for yet another markup language and the playbook is one of the core features of ansible and tell ansible what to execute.

There is a to-do list for ansible contains a list of task and playbooks contains step which to user wants to execute on a particular machine.

So playbook runs sequentially playbooks building block for all the use cases of ansible.

Tags in an ansible-playbook 

As we discussed earlier YAML starts with “—” and ends with “…” there are multiple tags available in YAML file lets go to them each and every tag.

Name :

The name tag will specify the name of the ansible-playbook. any logical name you can give to the playbook

Hosts :

The host specifies the host groups or hots against which we want to perform the task. host field in YAML is mandatory.

Vars :

Vars tag lets you define the variables which you can use in your playbook and usage is very similar to the variable in any programming languages.


All the playbook should contain a task or list of tasks to be executed.task is basically an action one needs to perform.


Hope this blog helps you to understand what is ansible and components of ansible.

To know more about the DevOps tool you can go through our blogs section where you will find each and every open-source DevOps tool.