Sunday, December 5, 2021

Installing and Configuring Ansible DevOps Environment in Ubuntu

Hi,
In this post we are going to concentrate on how to install Ansible and how to configure it...
 
Before we proceed on the installation part let me give you a brief note on what Ansible is....
 
Ansible is a radically simple IT automation platform that makes your application and system easier to deploy. Avoid writing scripts or custom code to deploy and update your applications - automate in a language that approaches plain English, using SSH, with no agents to install on remote system.
 
(the above description is inspired/copied from the description given when you add the repository for ansible in ubuntu)
 
Installing Ansible
 
Let us first add the repository 

$ sudo apt-add-repository ppa:ansible/ansible
if the above command prompts you for the password provide one associated with the user


$ sudo apt update
 

$ sudo apt install ansible
 
With this the installation part of ansible is complete, let us now concentrate on configuring it...
 
Configuring Ansible
Before you configure ansible you need identify the hosts that is going to be monitored by ansible.....
 
you can think of it in this way, the host/node where ansible is installed is called control node and the host/node entries that you have in the hosts file are called managed hosts/nodes
 
Using your favorite text editor open up the the file hosts which resides at /etc/ansible
 
$ sudo vi /etc/ansible/hosts

create groups and entries as directed by the image given below....

From the above image....

[servers] is the group which has the nodes to be managed...and you can as many groups as you want.
 
The [all:vars] subgroup tells the hosts/nodes about the interpreter to be used by the servers mentioned.

With this the configuration section of ansible is completed.

Testing Ansible

Let us try some command to see how Ansible works

Open a terminal and fire the commands below to see the output...

$ ansible-inventory --list -y
The above command would give the inventory list specified in the hosts file
 

 

$ ansible all -m ping -u root

This command would give you the ping result of all the hosts/nodes mentioned in the hosts file.


 
Well that is it... with this let us conclude this post.

 

No comments:

Post a Comment

How to change the root password in linux when it is forgotten/to change

This blog is all about changing the root password of the Linux system when it is forgotten or to reset the password...   Let's get it ...