How to Install Ansible on Amazon Linux 2023

How to Install Ansible on Amazon Linux 2023

How to Install Ansible on Amazon Linux 2023

Dear Reader, I hope you are doing amazing today. In the past, I have shared with you how to install Nginx, Apache Web Server, Docker, Java etc. on Amazon Linux 2023 EC2 Instance.

In today’s post, I will help you install Ansible on Amazon Linux 2023 EC2 instance.

So, are you ready?

Let’s start.

Don’t want to miss any posts from us? join us on our Facebook group, and follow us on Facebook, Twitter, LinkedIn, and Instagram. You can also subscribe to our newsletter below to not miss any updates from us.

Amazon Linux 2023 and Ansible

Amazon Linux 2023 or AL2023 is the next-generation Amazon Linux AMI provided by AWS. It is the successor of Amazon Linux 2 optimized for the cloud. It is designed with the latest Linux innovations to deliver high-performance and stable Linux systems.

Ansible is an open-source automation software written in Python. You can use it to automate application deployment, configuration management, cloud infrastructure provisioning, updating workstations and servers etc. other tasks

Prerequisite

First of all, before you install Ansible in your Amazon Linux 2023 or AL2023 EC2 instance, You need to have one EC2 instance up and running.

I have covered that in a separate post for you–

Additionally, if you don’t have a free tier account, check out how to setup a free tier AWS account in right way. Having said that, don’t forget to set up a cost budget to avoid last-minute billing shocks.

Background on Installing Ansible on Amazon Linux 2023

If you have installed Ansible in past on Amazon Linux 2, you will remember that Ansible is available on the Amazon Linux Extras repository as well as EPEL on Amazon Linux 2.

However, neither amazon-linux-extras nor EPEL is available on Amazon Linux 2023. You can read my below post to know details-

Having said that, there is a third way that you can use. Using pip – python package manager. Ansible itself is written in Python. And the official documentation even recommends installing Ansible using pip only.

So in this post, we will use pip to install Ansible on our Amazon Linux System.

Note: Pip is a package manager for Python. You can use it to install/manage packages that are not part of the Python standard library. Pip is the standard package manager for Python, and it is included in Python versions 3.4 and later

Steps to Install Ansible on Amazon Linux 2023 Instance

  1. SSH into your Amazon Linux 2023 Instance
  2. Update System Package
  3. Check If pip is installed on Amazon Linux 2023
  4. Check If Python is Available on AL2023
  5. Install pip on your System
  6. Install Ansible using pip
  7. Verify Ansible Installation

Step 1: SSH into your Amazon Linux 2023 Instance

I assume you already have an up-and-running Amazon Linux 2023 EC2 instance. In case you don’t already have an EC2 running, create one using one of my previous tutorials.

Once your instance is running, Let’s connect to it to be able to run commands so that we can install JavaAnsible on it.

If you are connecting to your instance from the local system, use the below SSH command and replace the public IP and path of the .pem file as per your need.

ssh -i /path/my-key-pair.pem ec2-user@instance-public-ip

I mostly use the EC2 instance connect option available from browser itself. Select your EC2 instance and click Connect.

How to Install Nginx on Amazon Linux 2023 Instance 1

Verify that ec2-user is showing in the user-name field and click Connect again.

In a matter of seconds, you are inside your instance as shown below.

Steps to Install Java on Amazon Linux 2023 Instance

Step 2: Update System Package

As always, you should update your system packages to the latest before installing any software.

You can run the system update using the below command-

sudo dnf update

Type sudo dnf update and hit enter.

How to Install Java on Amazon Linux 2023 Instance 1

Step 3: Check If pip is installed on Amazon Linux 2023

Before we can use pip to install any software packages on our Amazon Linux 2023, we need to check if pip is available on our system.

We can do that using-

pip --version
pip3 --version
How to Install Ansible on Amazon Linux 2023

Step 4: Check If Python is Available on AL2023

As we saw, pip3 is not available on a newly launched Amazon Linux 2023 instance. We will install it.

As pip is a Python package, the prerequisite to install pip is Python should be available in the system

Let’s check that-

python3 --version
Python on amazon linux 2023

As you can see python 3.9.16 is installed on my newly created Amazon Linux 2023 EC2 instance. We are all set to install pip on our system.

In case you need a different/latest version of Python, feel free to install it using-

 sudo dnf install python3.11

Step 5: Install pip3 on Amazon Linux 3

You can install pip3 using the below command-

sudo dnf install python3-pip
How to Install Ansible on Amazon Linux 2023 3

Type y and hit enter to install pip package.

Once installed, you can verify pip installation using the –

pip --version
Installed pip

If you have installed Python 3.11, you can install the corresponding pip using –

sudo dnf install  python3.11-pip

Step 6: Install Ansible using pip on Amazon Linux 2023

Install Ansible on Amazon Linux 2023 EC2 instance using pip as shown below-

pip install ansible
How to Install Ansible on Amazon Linux 2023 5

And Ansible gets installed under Python in our Amazon Linux 2023 Instance.

Step 5: Verify Ansible Installation

In the previous step, we installed Ansible on our Amazon Linux 2023 Ec2 instance.

Let’s verify that by firing the below command-

ansible --version
Successful Ansible Installation on Amazon linux 2023

And congratulation !!!

You have successfully installed Ansible on your Amazon Linux 2023 EC2 Instance.

Conclusion

In this how-to article, we discussed How to Install Ansible on Amazon Linux 2023 Instance. We learnt that Amazon Linux Extras and EPEL are not available on Amazon Linux 2023.

Therefore, we installed Ansible using pip on our Amazon Linux 2023 EC2 Instance. At last, we verified the Ansible installation and finished the post.

Were you able to install Ansible on Amazon Linux 2023 using this tutorial? Let me know in the comment section.

Enjoyed the content?

Subscribe to our newsletter below to get awesome AWS learning materials delivered straight to your inbox.

Don’t forget to motivate us-

Suggested Read:

One thought on “How to Install Ansible on Amazon Linux 2023

Leave a Reply

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