Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

How can we use Ansible and where?

Friends, First of all let’s know about Ansible is simple yet powerful. It is a great automation tool and does have great future. It is an open-source automation tool, or platform, used for IT tasks such as configuration management, application deployment, intraservice orchestration, and provisioning. It is one of the most easy to use, versatile and light tool for configuration management as well.

Ansible is a tool that provides:

How to Use Ansible?

Below you can see – Ansible consists of 3 main components. A brief explanation of each component is shown below:

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.

Ansible is a powerful IT automation tool that you can quickly learn. Its 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 image.

Now you can 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 image:

The main Benefits of Ansible

  • Ansible is fast and performs all functions over SSH and doesn’t require agent installation.
  • You can find Ansible to be a better fit in a larger or more homogeneous infrastructure.
  • It has a collection of modules that can be used to manage various systems as well as cloud infrastructure such as Amazon EC2 and openstack.
  • The main advantage is Ansible can be run from the command line without the use of configuration files for simple tasks, such as making sure a service is running, or to trigger updates or reboots.
  • As long as the box can be ssh’d into and it has python, it can be configured with Ansible.

Roles Directory Structure

Here i let you know about Roles Directory Structure of Ansible, Using Ansible Roles, expect files to be in a certain file structure. The most confusing part of using roles is understanding the file hierarchy. Ansible provides a feature called Ansible Galaxy that helps you play with roles. We already know where our Ansible is on Ubuntu (/etc/ansible). Have you ever seen a directory called roles under /etc/ansible? That directory exists exactly for this reason. You create different roles inside this directory.

The directory will look like this:

You can create a role using ansible-galaxy init command inside /etc/ansible/roles.

If you are planning to learn Ansible then go with below YouTube channel and get free Videos and Tutorials.

Thank you!

Rajesh Kumar
Follow me
Latest posts by Rajesh Kumar (see all)