Ansible Installation

In this series of Ansible we’ve already seen Introduction to Ansible its uses and advantages, Ansible Architecture and how does it work, In this post we will be seeing how to Install Ansible. We will be installing Ansible in EC2 linux machine CentOS.

So let’s get started with practical.

Login to AWS Console, create 2. t2 micro system.

Dashboard
Dashboard

Login to Ansible server and run below commands to install ansible

sudo apt update 
sudo apt install software-properties-common 
sudo apt-add-repository --yes --update ppa:ansible/ansible sudo apt install ansible

Verify ansible version and python version

Version
Version

Now login to Ansible node and install python, run below commands,

sudo apt update 
sudo apt install software-properties-common 
sudo apt-add-repository --yes --update ppa:ansible/ansible sudo apt install python

Verify the installation of Python, make sure you do not install Ansible on nodes,

Installation on node
Installation on node

Now login to Ansible master and generate private-public key pair to login to nodes, Run below commands to generate keys,

ssh-keygen -t rsa

Now navigate to .ssh folder and copy the content of id_rsa.pub from master and paste in the authorized_keys of node machines.

This will enable ssh keys based seamless authentication

Now open the default inventory file located in master by

vi /etc/ansible/hosts

Now add the servers as shown below, I’ve added my server in group appservers.

inventory
inventory

Now save the file and run below commands to check whether the node is connected or not, you should get below reply.

$ ansible appservers -m ping
Connection
Connection

Here you’re! You’ve successfully installed Ansible server and attached the node to Ansible server

Do let me know in the comment section if you face any queries.



Categories: Ansible, DevOps

Tags: , , , ,

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: