aws, ansible,

How to install Ansible on AWS EC2 Amazon Linux 2 instance

Oct 07, 2021 · 1 min read · Post a comment
How to install Ansible on AWS EC2 Amazon Linux 2 instance

When it comes to AWS hosted infrastructure, if there is a need for managing the instances or the deployments of the application/services you can use the approach of having one EC2 dedicated Ansible instance which will conduct all the necessary steps. In this tutorial, you are going to learn how to install Ansible on EC2 Amazon Linux 2 instance.

Prerequisites

  • AWS account
  • EC2 instance with Amazon Linux 2 template

Install Ansible on AWS EC2 Amazon Linux 2 instance

Step 1. Update the system packages:

sudo yum update

Step 2. Check if the EPEL repository is enabled:

sudo amazon-linux-extras list | grep epel

If the output is:

24  epel      available    [ =7.11  =stable ]

It means that you should enable it before installing Ansible.

Step 3. Enable the EPEL repo:

sudo amazon-linux-extras enable epel

Step 4. Install Ansible:

sudo yum install ansible

Step 5. To verify the installation run:

ansible --version

Output:

ansible 2.9.23
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible

Conclusion

Installing Ansible on AWS EC2 Amazon Linux 2 instance is pretty similar to the other RHEL based distros. If you have any concerns please let me know in the comments below. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on telegram.