How To Install Ansible – Step By Step Guide

In this lesson, you will learn the step by step guide of how to install ansible on a Linux system.


In the previous lesson on introduction to ansible, we understood what ansible is, the features of ansible and the basic architecture and overview of ansible setup.

One of the ansible features we talked about was the ansible control node. Hence, in this lesson, we are going to look at how to install the ansible software.

To install the ansible software on a Red Hat Enterprise Linux eight (RHEL 8) system, the ansible repository has to be enabled.

One out of two repositories that can be enabled is the repository related to minor releases and the second is a repository related to a major release.

The minor release is repository specific to a particular version of the ansible software one wants to install. For example, if you want to install the ansible version of 2.8, you can enable “ansible-2.8-for-rhel-8-x86_64-rpms” repository.

On the other hand, a major release is a general ansible repository, “ansible-2-for-rhel-8-x86_64-rpms”. It allows one to install the latest version of ansible.

When this repository is enabled, a “dnf install” or a “dnf update” command will install the latest version.

The command below can be used to verify the major and minor releases of ansible 2 as of when this article is written.

[root@DRDEV1 ~]# subscription-manager repos --list |grep ansible-2*

Repo ID:   ansible-2-for-rhel-8-x86_64-debug-rpms
Repo ID:   ansible-2.8-for-rhel-8-x86_64-rpms
Repo ID:   ansible-2-for-rhel-8-x86_64-source-rpms
Repo ID:   ansible-2.8-for-rhel-8-x86_64-debug-rpms
Repo ID:   ansible-2.9-for-rhel-8-x86_64-source-rpms
Repo ID:   ansible-2.8-for-rhel-8-x86_64-source-rpms
Repo ID:   ansible-2.9-for-rhel-8-x86_64-rpms
Repo ID:   ansible-2-for-rhel-8-x86_64-rpms
Repo ID:   ansible-2.9-for-rhel-8-x86_64-debug-rpms


Step By Step Guide Of How To Install Ansible On RHEL 8

1. Enable the Red Hat repository for ansible.

As mentioned in the “UNDERSTANDING THE SUBJECT MATTER” section above, any of the repositories depending on the ansible version you need can be enabled.

[root@DRDEV1 ~]# subscription-manager repos --enable ansible-2.8-for-rhel-8-x86_64-rpms

Repository 'ansible-2.8-for-rhel-8-x86_64-rpms' is enabled for this system.

2. Install ansible

[root@DRDEV1 ~]# dnf install ansible

Updating Subscription Management repositories.
Red Hat Ansible Engine 2.8 for RHEL 8 x86_64 (RPMs)              
Dependencies resolved.

3. Verify the ansible version installed.

[root@DRDEV1 ~]# ansible --version
ansible 2.8.18
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share                 /ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, Oct 11 2019, 15:04:54) [GCC 8.3.1 20190507 (R                 ed Hat 8.3.1-4)]

You can see the ansible version is 2.8.18 and the ansible python version is 3.6.8.

You can also use the command below to verify the ansible python version.

[root@DRDEV1 ~]# ansible -m setup localhost | grep ansible_python_version

        "ansible_python_version": "3.6.8",

Class Activity

Having understood what ansible is in the previous lesson and how to install ansible in this lesson, create a lab and install the latest release of ansible and state your challenges in the comment section below.

If you like this article, you can support us by

1. sharing this article.

2. Buying the article writer a coffee (click here to buy a coffee)

3. Donating to push our project to the next level. (click here to donate)

If you need personal training, send an email to

install ansible

Click Here To Watch Video On How To Install Ansible On RHEL 8

RHCE Exam Practice Question & Answer On How To Install Ansible

Your feedback is welcomed. If you love others, you will share with others

Be the first to comment

Leave a Reply

Your email address will not be published.