Ansible installation and configuration on AWS EC2 instance
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 🙂