What is Ansible and How it Works?

Image for post
Image for post

What is Ansible?

If you are a system administrator or IT engineer you probably involved in doing a lot of repetitive task in your environment whether it be sizing, creating a new house or virtual machines every day, applying configuration on them, patching hundreds of servers, migration or even performing security and compliance audits. All of these very repetitive tasks involve the execution of hundreds of commands on hundreds of different servers. Smart people develop a script to automate these tasks but it requires coding skills and regular maintenance of this script and a lot of time to put this script together in the first place. That’s where the Ansible comes in the picture.

Ansible is a powerful IT automation tool that you can quickly learn. It’s simple enough for everyone in IT yet powerful enough to automate even the most complex deployment.

Simple — Use Case Example

Let’s take a look at a simple use case shown in the following screen.

Image for post
Image for post

Imagine you have a number of servers in your environment that you would like to restart in a particular order. Some of them are web servers and others are database servers. So you would like to power down the webserver first followed by the database servers then powerup the database servers and then webservers. You could write an Ansible playbook to get this done in a minute and simply invoke the Ansible playbook every time you wish to restart your applications.

Complex — Use Case Example

Let’s take a look at a complex use case as shown in the following screen:

Image for post
Image for post

In this case, we are setting up a complex infrastructure that spans across public and private clouds, and hundreds of VMs. With Ansible you could provision VMs on a public cloud like AWS and provision private cloud in private cloud setup like Vmware based infrastructure and move on to configuring applications on those systems and setup communication between them. There are a lot of modules available in Ansible that support this kind of operation.

Ansible Features

One of the main features of Ansible is that you don’t need to install any agent or additional software on the target host. It provides powerful features to manage operating systems, services, networks and infrastructure.

Some of the important features of Ansible are listed below:

  1. Free : It is an open-source tool and is available to the users for free of cost.

How Ansible Works?

Ansible consists of 3 main components. A brief explanation of each component is shown below:

Image for post
Image for post

Control Machine : It manages the execution of the Playbook. It can be installed on your local machine or on any machine on the internet.

Inventory : It provides a complete list of all the target machines on which various modules are run by doing an ssh connection and install the necessary software.

Playbook : It consists of steps that the control mechanism will perform on the servers defined in the inventory file.

In simple terms, Ansible interacts with all the servers defined in the inventory through the SSH protocol which is a secure method of remote login. Every operation is done and file transfer is encrypted.

For more information, read my complete guide on Ansible for Beginners

Original Source:

Written by

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store