Ankit Cse
3 min readFeb 9, 2021

--

How to Setup Ansible on the Controller node present in AWS

Hello Guys, Today I will show you how you can setup Ansible on the Controller node present in AWS.

So, let’s get started ….

For installing the Ansible software on Amazon Linux2 AMI follow the below steps :-

Step 1 — Install the latest version of packages

$ sudo yum update -y

Step 2 — Use the amazon-linux-extras command to install ansible.

$ sudo amazon-linux-extras install ansible2 -y

Step 3– Check Ansible Version

$ ansible --version

Step4 — Now comes the installation of rpm of sshpass in order to go into the managed nodes for that we use the below mentioned command:-

sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

Step5-After installing the rpm of sshpass you can install the package using the below mentioned command.

sudo yum install sshpass -y

Step6- Check whether the sshpass is installed or not using the below mentioned command:-

rpm -q sshpass

Step7:- Upload the key-pair in the home directory of Controller Node See the below picture:-

After uploading the key pair, provide permissions to the key pair using the below mentioned command :-

chmod 400 name_of_your_key_pair.pem

Step8- Creating the Inventory

In the inventory write down the following details mentioned below:-

Step9:- Now Come to the config file of Ansible

Go into the config file using the below mentioned command :-

sudo vim /etc/ansible/ansible.cfg

Add the following information in the config file of ansible but don’t forget to remove the config file already present in ansible . Because the way by which we have installed the ansible it has already config file present in it

So, use the below the command to remove the config file

sudo rm -rf /etc/ansible/ansible.cfg

Then create the config file using the below command

sudo vim /etc/ansible/ansible.cfg

Add these details into the config file of ansible

Now everything is setup inventory as well as the config file of ansible

Now you can use the below commands:-

1. To check the number of hosts :- ansible all —-list-hosts2. To ping the managed nodes :- ansible all -m ping

That’s all from my side. I hope you enjoyed the article . If you really enjoyed it give it a clap and share your valuable feedback with me. For getting more articles like this in your feed follow me on medium.

That’s all signing off …

--

--