How to install ansible in RHEL 8 - a simple & practical guide

How to install ansible in RHEL 8 – a simple & practical guide

Last Updated on April 15, 2023 by cscontents

Introduction

Ansible is a very powerful open-source IT automation tool. It is known as a configuration management tool. Ansible is written in Python language, so it requires Python to be available on the machine. We can use Ansible to automate software installation, software configuration, configuration management, etc.

To get a quick high-level understanding of Ansible, please review the article below.

https://cscontents.com/introduction-to-ansible/

To use Ansible for your automation purpose you would need a machine where Ansible needs to be installed and this is called ansible-host or ansible-controller. And you would need other machines (remote or target machines) where Ansible will perform the tasks.

There are multiple ways to install Ansible in RHEL. Below are the two most used methods.

  • Ansible installation using RHEL package manager.
  • Ansible installation using the pip module of Python.

In this article, we will see how to install Ansible using the RHEL package manager in a step-by-step manner.

Prerequisite

  • Since we will install Ansible on RHEL (Red Hat Enterprise Linux), you must have an RHEL machine connected to the Red Hat subscription manager.
  • On the RHEL machine, you would need a user which has sudo privileges.

Steps/Commands to install Ansible

As of April 2023, the latest version of Ansible is 2.13.x (ansible core). We will be installing the same.

We will be using dnf to install Ansible. (dnf is the package management utility for RHEL, Fedora, and Centos).

Step 1: Update OS

# Run the below command to update the RHEL OS.

sudo dnf update -y

Step 2: Install Python

# Check whether Python is installed or not. RHEL 8 comes with python3. So, we don’t need to install Python.

python3 -V

# If Python is not installed, then run the below command to install it.

sudo dnf install python3

Step 3: Enable repos for Ansible

# List the available repos that include ansible-core packages

sudo dnf list ansible-core

OR

sudo dnf info ansible-core

In the output of the above, we will see the repo name. We need to enable that repo.

# Enable the repo that includes the ansible-core package.

sudo subscription-manager repos --enable <repo name>

Step 4: Install Ansible

# Run the below commands to install Ansible

sudo dnf install ansible -y

# Finally, we can check the version of Ansible.

ansible --version

Apart from the above method of Ansible installation, we can install Ansible by following the official documentation of Ansible.

https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-and-upgrading-ansible

 

Thank You.

If you are interested in learning DevOps, please have a look at the below articles, which will help you greatly.