Day 57: Ansible Hands-on with video   (Jan 22, 2024)

Day 57: Ansible Hands-on with video (Jan 22, 2024)

🙏 Introduction:

In this blog, Today we will write a blog explanation for the Ansible Tutorial for DevOps Engineers

🎯Task: 1

Write a Blog explanation for the ansible video

  • Create an EC2 instance

  • Connect to your EC2 instance using SSH

  • Add the Ansible PPA repository

  • Update the package

  • Install Ansible

  • check the version of Ansible

  • Launch three new EC2 instances with same private key as Ansible-master-node EC2 instance.

  • Copy the private key to master server where Ansible is setup

  • In master node where ansible is setup, create a new file at location /home/ubuntu/.ssh and paste private key to that file.

  • SSH into Ansible server instances from master instance by using private key
sudo ssh -i /key-path ubuntu@public-ip-address

  • Create an inventory file for Ansible that lists the IP addresses of the Ansible server

  • Create a new folder named ansible, inside folder create hosts file which is inventory file for ansible. add the IP addresses of the servers inside hosts file.

server1 ansible_host= 
server2 ansible_host=
server3 ansible_host=


  • To verify the inventory of hosts
ansible-inventory --list -y -i <inventory-file-path>

  • Change the private key permission (ansible_key)

  • Specify the private key file to use for authentication using the --private-key option when running the Ansible command
ansible -i <inventory_file> all -m ping --private-key=<path_to_private_key>

  • Ansible command to check the free memory
ansible -i /home/ubuntu/ansible/hosts all -a "free -m" --private-key=/home/ubuntu/.ssh/ansible_key

  • Ansible command to check uptime
ansible -i /home/ubuntu/ansible/hosts all -a "uptime" --private-key=/home/ubuntu/.ssh/ansible_key