How to install Ansible in Red Hat Enterprise Linux version 8. Today we’re going to talk about the easier way to install and maintain Ansible inside RHEL 8 with the distribution tools. I’m Luca Berton and welcome to today’s episode of Ansible Pilot.

How to install Ansible in RHEL 8

Today we’re talking about How to install Ansible in RHEL 8. The easier way to install and maintain Ansible inside Red Hat Enterprise Linux version 8 with the distribution tools. The repository that contains Ansible is called the Ansible Engine software collection. The main advantage of using software collection is that you don’t require any external repository such as EPEL for this content. Software Collections are fully supported by Red Hat and included in your subscription plan.

Demo

Are you ready to make your hands dirty? Let’s jump in a quick live Playbook of how to install the latest and a specific version of Ansible in RHEL8.

RedHat Enterprise Linux (RHEL) 8 supports ansible-core via the

code

#!/bin/bash
sudo subscription-manager register
sudo subscription-manager repos --enable ansible-2.9-for-rhel-8-x86_64-rpms
sudo yum install ansible

Execution

# dnf install ansible-core
Updating Subscription Management repositories.
Dependencies resolved.
===================================================================================================
 Package                  Arch     Version                Repository                          Size
===================================================================================================
Installing:
 ansible-core             x86_64   2.12.2-1.el9           rhel-9-for-x86_64-appstream-rpms   2.4 M
Installing dependencies:
 emacs-filesystem         noarch   1:27.2-6.el9           rhel-9-for-x86_64-appstream-rpms    10 k
 git                      x86_64   2.31.1-2.el9.2         rhel-9-for-x86_64-appstream-rpms   128 k
 git-core                 x86_64   2.31.1-2.el9.2         rhel-9-for-x86_64-appstream-rpms   3.6 M
 git-core-doc             noarch   2.31.1-2.el9.2         rhel-9-for-x86_64-appstream-rpms   2.5 M
 perl-AutoLoader          noarch   5.74-479.el9           rhel-9-for-x86_64-appstream-rpms    31 k
 perl-B                   x86_64   1.80-479.el9           rhel-9-for-x86_64-appstream-rpms   194 k
 perl-Carp                noarch   1.50-460.el9           rhel-9-for-x86_64-appstream-rpms    31 k
 perl-Class-Struct        noarch   0.66-479.el9           rhel-9-for-x86_64-appstream-rpms    32 k
 perl-Data-Dumper         x86_64   2.174-462.el9          rhel-9-for-x86_64-appstream-rpms    59 k
 perl-Digest              noarch   1.19-4.el9             rhel-9-for-x86_64-appstream-rpms    29 k
 perl-Digest-MD5          x86_64   2.58-4.el9             rhel-9-for-x86_64-appstream-rpms    39 k
 perl-DynaLoader          x86_64   1.47-479.el9           rhel-9-for-x86_64-appstream-rpms    36 k
 perl-Encode              x86_64   4:3.08-462.el9         rhel-9-for-x86_64-appstream-rpms   1.7 M
 perl-Errno               x86_64   1.30-479.el9           rhel-9-for-x86_64-appstream-rpms    25 k
 perl-Error               noarch   1:0.17029-7.el9        rhel-9-for-x86_64-appstream-rpms    46 k
 perl-Exporter            noarch   5.74-461.el9           rhel-9-for-x86_64-appstream-rpms    34 k
 perl-Fcntl               x86_64   1.13-479.el9           rhel-9-for-x86_64-appstream-rpms    32 k
 perl-File-Basename       noarch   2.85-479.el9           rhel-9-for-x86_64-appstream-rpms    27 k
 perl-File-Find           noarch   1.37-479.el9           rhel-9-for-x86_64-appstream-rpms    36 k
 perl-File-Path           noarch   2.18-4.el9             rhel-9-for-x86_64-appstream-rpms    38 k
 perl-File-Temp           noarch   1:0.231.100-4.el9      rhel-9-for-x86_64-appstream-rpms    63 k
 perl-File-stat           noarch   1.09-479.el9           rhel-9-for-x86_64-appstream-rpms    27 k
 perl-FileHandle          noarch   2.03-479.el9           rhel-9-for-x86_64-appstream-rpms    26 k
 perl-Getopt-Long         noarch   1:2.52-4.el9           rhel-9-for-x86_64-appstream-rpms    64 k
 perl-Getopt-Std          noarch   1.12-479.el9           rhel-9-for-x86_64-appstream-rpms    26 k
 perl-Git                 noarch   2.31.1-2.el9.2         rhel-9-for-x86_64-appstream-rpms    45 k
 perl-HTTP-Tiny           noarch   0.076-460.el9          rhel-9-for-x86_64-appstream-rpms    58 k
 perl-IO                  x86_64   1.43-479.el9           rhel-9-for-x86_64-appstream-rpms   103 k
 perl-IO-Socket-IP        noarch   0.41-5.el9             rhel-9-for-x86_64-appstream-rpms    45 k
 perl-IPC-Open3           noarch   1.21-479.el9           rhel-9-for-x86_64-appstream-rpms    34 k
 perl-MIME-Base64         x86_64   3.16-4.el9             rhel-9-for-x86_64-appstream-rpms    34 k
 perl-Net-SSLeay          x86_64   1.92-1.el9             rhel-9-for-x86_64-appstream-rpms   392 k
 perl-POSIX               x86_64   1.94-479.el9           rhel-9-for-x86_64-appstream-rpms   108 k
 perl-PathTools           x86_64   3.78-461.el9           rhel-9-for-x86_64-appstream-rpms    92 k
 perl-Pod-Escapes         noarch   1:1.07-460.el9         rhel-9-for-x86_64-appstream-rpms    22 k
 perl-Pod-Perldoc         noarch   3.28.01-461.el9        rhel-9-for-x86_64-appstream-rpms    92 k
 perl-Pod-Simple          noarch   1:3.42-4.el9           rhel-9-for-x86_64-appstream-rpms   229 k
 perl-Pod-Usage           noarch   4:2.01-4.el9           rhel-9-for-x86_64-appstream-rpms    43 k
 perl-Scalar-List-Utils   x86_64   4:1.56-461.el9         rhel-9-for-x86_64-appstream-rpms    77 k
 perl-SelectSaver         noarch   1.02-479.el9           rhel-9-for-x86_64-appstream-rpms    22 k
 perl-Socket              x86_64   4:2.031-4.el9          rhel-9-for-x86_64-appstream-rpms    58 k
 perl-Storable            x86_64   1:3.21-460.el9         rhel-9-for-x86_64-appstream-rpms    98 k
 perl-Symbol              noarch   1.08-479.el9           rhel-9-for-x86_64-appstream-rpms    24 k
 perl-Term-ANSIColor      noarch   5.01-461.el9           rhel-9-for-x86_64-appstream-rpms    51 k
 perl-Term-Cap            noarch   1.17-460.el9           rhel-9-for-x86_64-appstream-rpms    24 k
 perl-TermReadKey         x86_64   2.38-11.el9            rhel-9-for-x86_64-appstream-rpms    40 k
 perl-Text-ParseWords     noarch   3.30-460.el9           rhel-9-for-x86_64-appstream-rpms    18 k
 perl-Text-Tabs+Wrap      noarch   2013.0523-460.el9      rhel-9-for-x86_64-appstream-rpms    25 k
 perl-Time-Local          noarch   2:1.300-7.el9          rhel-9-for-x86_64-appstream-rpms    37 k
 perl-URI                 noarch   5.09-3.el9             rhel-9-for-x86_64-appstream-rpms   125 k
 perl-base                noarch   2.27-479.el9           rhel-9-for-x86_64-appstream-rpms    26 k
 perl-constant            noarch   1.33-461.el9           rhel-9-for-x86_64-appstream-rpms    25 k
 perl-if                  noarch   0.60.800-479.el9       rhel-9-for-x86_64-appstream-rpms    24 k
 perl-interpreter         x86_64   4:5.32.1-479.el9       rhel-9-for-x86_64-appstream-rpms    83 k
 perl-lib                 x86_64   0.65-479.el9           rhel-9-for-x86_64-appstream-rpms    25 k
 perl-libnet              noarch   3.13-4.el9             rhel-9-for-x86_64-appstream-rpms   134 k
 perl-libs                x86_64   4:5.32.1-479.el9       rhel-9-for-x86_64-appstream-rpms   2.2 M
 perl-mro                 x86_64   1.23-479.el9           rhel-9-for-x86_64-appstream-rpms    40 k
 perl-overload            noarch   1.31-479.el9           rhel-9-for-x86_64-appstream-rpms    56 k
 perl-overloading         noarch   0.02-479.el9           rhel-9-for-x86_64-appstream-rpms    23 k
 perl-parent              noarch   1:0.238-460.el9        rhel-9-for-x86_64-appstream-rpms    16 k
 perl-podlators           noarch   1:4.14-460.el9         rhel-9-for-x86_64-appstream-rpms   118 k
 perl-subs                noarch   1.03-479.el9           rhel-9-for-x86_64-appstream-rpms    22 k
 perl-vars                noarch   1.05-479.el9           rhel-9-for-x86_64-appstream-rpms    23 k
 python3-babel            noarch   2.9.1-2.el9            rhel-9-for-x86_64-appstream-rpms   6.0 M
 python3-cffi             x86_64   1.14.5-5.el9           rhel-9-for-x86_64-appstream-rpms   257 k
 python3-cryptography     x86_64   36.0.1-1.el9_0         rhel-9-for-x86_64-appstream-rpms   1.2 M
 python3-jinja2           noarch   2.11.3-4.el9           rhel-9-for-x86_64-appstream-rpms   253 k
 python3-markupsafe       x86_64   1.1.1-12.el9           rhel-9-for-x86_64-appstream-rpms    39 k
 python3-packaging        noarch   20.9-5.el9             rhel-9-for-x86_64-appstream-rpms    81 k
 python3-ply              noarch   3.11-14.el9            rhel-9-for-x86_64-appstream-rpms   111 k
 python3-pycparser        noarch   2.20-6.el9             rhel-9-for-x86_64-appstream-rpms   139 k
 python3-pyparsing        noarch   2.4.7-9.el9            rhel-9-for-x86_64-baseos-rpms      154 k
 python3-pytz             noarch   2021.1-4.el9           rhel-9-for-x86_64-appstream-rpms    56 k
 python3-resolvelib       noarch   0.5.4-5.el9            rhel-9-for-x86_64-appstream-rpms    38 k
 sshpass                  x86_64   1.09-4.el9             rhel-9-for-x86_64-appstream-rpms    30 k
Installing weak dependencies:
 perl-IO-Socket-SSL       noarch   2.073-1.el9            rhel-9-for-x86_64-appstream-rpms   223 k
 perl-Mozilla-CA          noarch   20200520-6.el9         rhel-9-for-x86_64-appstream-rpms    14 k
 perl-NDBM_File           x86_64   1.15-479.el9           rhel-9-for-x86_64-appstream-rpms    33 k
Transaction Summary
===================================================================================================
Install  80 Packages
Total download size: 25 M
Installed size: 102 M
Is this ok [y/N]: y
[...]

Verification

After the successful installation you could verify in the command line:

[root@localhost ~]# ansible --version
ansible [core 2.12.2]
  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.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.10 (main, Feb  9 2022, 00:00:00) [GCC 11.2.1 20220127 (Red Hat 11.2.1-9)]
  jinja version = 2.11.3
  libyaml = True

code with ❤️ in GitHub

Conclusion

Now you know how to install the latest and a specific version of Ansible in RHEL8. Subscribe to the YouTube channel, Medium, and Website, X (formerly Twitter) to not miss the next episode of the Ansible Pilot.

Academy

Learn the Ansible automation technology with some real-life examples in my Udemy 300+ Lessons Video Course.

BUY the Complete Udemy 300+ Lessons Video Course

My book Ansible By Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps

BUY the Complete PDF BOOK to easily Copy and Paste the 250+ Ansible code

Want to keep this project going? Please donate

Patreon Buy me a Pizza