ansible, aws, amazon linux 2,

How to install Ansible on Amazon Linux 2

Oct 07, 2021 · 1 min read · Post a comment

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

  • Amazon Linux 2
  • sudo privileges

Install Ansible on AWS EC2 Amazon Linux 2 instance

Step 1. Update system packages.

sudo yum update

Step 2. Check if ansible2 repository is enabled.

sudo amazon-linux-extras list | grep ansible2

Step 3. If not, enable the ansible2 repo.

sudo amazon-linux-extras enable ansible2

Step 4. Install Ansible.

sudo yum install -y 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.