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

Step 1: Login to Ansible server and run below commands, become root user and enable password based authentication

vi /etc/ssh/sshd_config 
change the contents 
# PasswordAuthentication no  => PasswordAuthentication yes 
service sshd restart

Step 2: Create a user devops and give sudo permission to the user

adduser devops 
visudo  
# Add in the file opened  
devops  ALL=(ALL:ALL) NOPASSWD:ALL 

# To test this 
su devops 
sudo apt-get update 
# It should not ask for password and it should complete the command execution

Step 3: 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 run Step 1 and 2 and run below step

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

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

Installation on node
Installation on node

Login into ACS/Master as devops and configure password less login into node

ssh devops@<acspublicip> 
ssh-keygen 
ssh-copy-id devops@<nodeprivateip>

Do the following to test connectivity

sudo mv /etc/ansible/hosts /etc/ansible/hosts.backup
sudo vi /etc/ansible/hosts 
# add node1-private ip and save the file 
# check by executing 
ansible -m ping all

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.

One thought on “Ansible Installation

Leave a comment