Ansible installation and configuration on AWS EC2 instance

If you found this post helpful, kindly share it and show your support :)

This document will help you to install and configuration on AWS EC2 instance. I will install Ansible on the Ansible Control Node and configure SSH access to Ansible Host.

Here, I have used one AWS instance for Ansible control node and one AWS instance for Ansible host. Both servers are using Ubuntu 18.04.

Install Ansible on Ansible control Node

  • To update the Ansible control Node, run
sudo apt-get update
  • To install software-properties-common. It manages your distribution and independent software vendor software sources.
sudo apt install software-properties-common 
  • Add the following ppa(Personal Package Archives) to your System.
sudo apt-add-repository ppa:ansible/ansible
  • To update the server, run
sudo apt update 
  • To Install ansible, run
sudo apt install ansible
  • To check Ansible Version, run
ansible --version

From the Ansible Host,

  • To update Ansible Host, run
sudo apt-get update
  • To install python, run
sudo apt-get install python

Configure SSH access to Ansible Host (For Keyless SSH)

  • From the Ansible control Node, run the below command to generate a private key (id_rsa) and public key (id_rsa.pub)
ssh-keygen
  • Copy public-key (id_rsa.pub) and add it to the file .ssh/authorized_keys in the Ansible Host.
  • Permission of private key (id_rsa) should be 400.
sudo vi .ssh/authorized_keys

For setting up Ansible Host and testing connection:-

  • Add following lines to the file /etc/ansible/hosts
[servers]
host1 ansible_ssh_host=public_ip_of_host 
  • Check connectivity to all hosts using the following command.
ansible -m ping all

Output like this :

That’s it 🙂

Loading

Mohammed Noufal

I'm Mohammed Noufal, working as Server Admin for the last 10 years.  In my day-to-day life, l had to face different problems related to Web-hosting. On my website Errorlogz.com, you can find solutions for different Web-hosting-related problems. Sometimes, I spent hours searching/googling to find a solution. This inspired me to start a website that gives solutions to different Webhosting problems. This website includes basic Linux and windows commands, and different control panels like cPanel, Plesk, DirectAdmin, Webmin & so on. You can find solutions and or suggestions for different Web-hosting related problems from here. Hence I would like to say Errorlogz is your server protector.  I will be glad if Logdetect can help any one of the Server admins to find a solution to his problem.

Leave a Reply

Your email address will not be published. Required fields are marked *