Tuesday 9 August 2016

Unknown

Ansible



Ansible is the simplest way to deploy your applications on multiple remote machines. It works without any human interface that means it is agentless. Being a very intelligent automation system it is very easy to use.
There are multiple other options available, mainly puppet and chef, but unlike Ansible they require additional packages to be installed on remote nodes.So after breaking the above, one can understand that Ansible is:


  1.      Agentless
  2.      Easy to use 
  3.      Intelligent automation system
  4.      Unlike other configuration management tools like puppet and chef, in Ansible there is no need of installing any additional packages on remote nodes.


THINGS REQUIRED FOR IMPLEMENTATION:

    1. Basic knowledge of 'how to use vim'.
    2. The password-less connection between local and remote nodes.
*To know how to establish 'Password-less connection between local and remote hosts' click here.
*Python is required, but as in most Linux OS, python is already installed, you don't need to install it again.

INSTALLING ANSIBLE:

As mentioned above, we don't need to install anything on the remote machine, whatever we do, will be on localhost i.e the controller. (Remote machines will be called guests)
in the controller, to install ansible, type

#dnf install -y ansible

INVENTORY FILE:

It is a simple text file that stores the location of all the guests. You can manually add any number of guests you want. By default, it is stored in directory ' /etc/ansible/hosts' but you can change it to any directory you want.
access it with vim.

Type #vim /etc/ansible/hosts

Go to the end of file and type your group name, in square brackets. Followed by that, type your guests IP addresses. Below is the example of it.

[web-servers]
192.168.99.
192.168.99. 


In the picture above, 192.168.56.101 and 192.168.56.101 are my guests. Note that you can any number of guests. Also, web-servers is my group name.
*Before adding IP addresses, make sure you have established the password-less connection between the controller and all the guests.

TESTING CONNECTION:

Now you are ready to deploy the commands. Let's ping the guests and check if the [web-servers] is properly connected or not.

Type #ansible -m ping web-servers in the controller to ping guests in web-servers.

If everything is done, it will give results similar to the pic below:


There are too many modules available that you can use for different operations. To know more about the modules, click here.
As we have tested the connection, blog ends here. In next blog, we will see ansible in detail and learn about playbooks that can deploy multiple packages at once.

In the end, I would like to thank Buvanesh (a Red Hat intern), who patiently taught me ansible, playbooks and a lot of other things.Here is his blog link. Thank you!

Unknown

About Unknown -

FOSS enthusiast, Linux evangelist and a programmer heart and soul. In love with Python and C. I contribute to fedora project and seek opportunities to learn more.

Subscribe to this Blog via Email :