Ansible Pilot

How to install Ansible in Rocky Linux 9 - Ansible install

How to install and maintain up-to-date Ansible inside Rocky Linux 9 using DNF and the ”appstream” system repository.

July 19, 2022
Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons

How to install Ansible in Rocky Linux version 9.

Today we’re going to talk about the easier way to install and maintain Ansible inside Rocky Linux 9 using the appstream system repository. I’m Luca Berton and welcome to today’s episode of Ansible Pilot.

How to install Ansible in Rocky Linux 9

Today we’re talking about How to install Ansible in Rocky Linux 9.

The easier way to install and maintain up-to-date Ansible inside Rocky Linux version 9 is using the ansible-core package included in the AppStream distribution repository. Please notice that the package ansible isn’t available anymore. It’s not necessary to use the additional EPEL package repository.

See also: Ansible terminology - ansible vs ansible-core packages.

The Best Resources For Ansible

Video Course

Printed Book

eBooks

demo

Let’s jump into a quick live demo of how to install the latest version of Ansible in Rocky Linux. I’m going to install the ansible-core package in an Rocky Linux 9 using the AppStream distribution repository.

code

#!/bin/bash
sudo dnf install ansible-core

execution

ansible-pilot $ ssh [email protected]
Last login: Tue Jul 19 11:17:44 2022 from 192.168.43.5
[devops@rockylinux ~]$ sudo su
[root@rockylinux devops]# cat /etc/redhat-release 
Rocky Linux release 9.0 (Blue Onyx)
[root@rockylinux devops]# cat /etc/os-release 
NAME="Rocky Linux"
VERSION="9.0 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.0"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.0 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.0"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.0"
[root@rockylinux devops]# hostnamectl 
 Static hostname: rockylinux.example.com
       Icon name: computer-vm
         Chassis: vm 🖴
      Machine ID: 26419e43cdb741a2a2068070219bf8d9
         Boot ID: bed36d9812744b248bc8f674343c83c9
  Virtualization: oracle
Operating System: Rocky Linux 9.0 (Blue Onyx)      
     CPE OS Name: cpe:/o:rocky:rocky:9::baseos
          Kernel: Linux 5.14.0-70.13.1.el9_0.x86_64
    Architecture: x86-64
 Hardware Vendor: innotek GmbH
  Hardware Model: VirtualBox
[root@rockylinux devops]# uname -a
Linux rockylinux.example.com 5.14.0-70.13.1.el9_0.x86_64 #1 SMP PREEMPT Wed May 25 21:01:57 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
[root@rockylinux devops]# dnf search ansible
Last metadata expiration check: 1:08:16 ago on Tue 19 Jul 2022 10:15:38 AM UTC.
================================= Name & Summary Matched: ansible =================================
ansible-collection-microsoft-sql.noarch : The Ansible collection for Microsoft SQL Server
                                        : management
ansible-collection-redhat-rhel_mgmt.noarch : Ansible Collection of general system management and
                                           : utility modules and other plugins
ansible-freeipa-tests.noarch : ansible-freeipa tests
ansible-pcp.noarch : Ansible Metric collection for Performance Co-Pilot
ansible-test.x86_64 : Tool for testing ansible plugin and module code
====================================== Name Matched: ansible ======================================
ansible-core.x86_64 : SSH-based configuration management, deployment, and task execution system
ansible-freeipa.noarch : Roles and playbooks to deploy FreeIPA servers, replicas and clients
==================================== Summary Matched: ansible =====================================
rhc-worker-playbook.x86_64 : Python worker for Red Hat connector that launches Ansible Runner
[root@rockylinux devops]# dnf info ansible-core
Last metadata expiration check: 1:08:24 ago on Tue 19 Jul 2022 10:15:38 AM UTC.
Available Packages
Name         : ansible-core
Version      : 2.12.2
Release      : 1.el9.rocky.0.1
Architecture : x86_64
Size         : 2.0 M
Source       : ansible-core-2.12.2-1.el9.rocky.0.1.src.rpm
Repository   : appstream
Summary      : SSH-based configuration management, deployment, and task execution system
URL          : http://ansible.com
License      : GPLv3+
Description  : Ansible is a radically simple model-driven configuration management,
             : multi-node deployment, and remote task execution system. Ansible works
             : over SSH and does not require any software or daemons to be installed
             : on remote nodes. Extension modules can be written in any language and
             : are transferred to managed machines automatically.

[root@rockylinux devops]# dnf list ansible-core
Last metadata expiration check: 1:08:31 ago on Tue 19 Jul 2022 10:15:38 AM UTC.
Available Packages
ansible-core.x86_64                        2.12.2-1.el9.rocky.0.1                         appstream
[root@rockylinux devops]# dnf install ansible-core
Last metadata expiration check: 1:08:45 ago on Tue 19 Jul 2022 10:15:38 AM UTC.
Dependencies resolved.
===================================================================================================
 Package                     Architecture  Version                          Repository        Size
===================================================================================================
Installing:
 ansible-core                x86_64        2.12.2-1.el9.rocky.0.1           appstream        2.0 M
Installing dependencies:
 emacs-filesystem            noarch        1:27.2-6.el9                     appstream        8.4 k
 git                         x86_64        2.31.1-2.el9.2                   appstream        120 k
 git-core                    x86_64        2.31.1-2.el9.2                   appstream        3.6 M
 git-core-doc                noarch        2.31.1-2.el9.2                   appstream        2.3 M
 perl-Error                  noarch        1:0.17029-7.el9                  appstream         41 k
 perl-Git                    noarch        2.31.1-2.el9.2                   appstream         43 k
 python3-babel               noarch        2.9.1-2.el9                      appstream        5.8 M
 python3-cffi                x86_64        1.14.5-5.el9                     appstream        241 k
 python3-cryptography        x86_64        36.0.1-1.el9_0                   appstream        1.1 M
 python3-jinja2              noarch        2.11.3-4.el9                     appstream        229 k
 python3-markupsafe          x86_64        1.1.1-12.el9                     appstream         32 k
 python3-packaging           noarch        20.9-5.el9                       appstream         69 k
 python3-ply                 noarch        3.11-14.el9                      appstream        103 k
 python3-pycparser           noarch        2.20-6.el9                       appstream        124 k
 python3-pytz                noarch        2021.1-4.el9                     appstream         48 k
 python3-pyyaml              x86_64        5.4.1-6.el9                      baseos           191 k
 python3-resolvelib          noarch        0.5.4-5.el9                      appstream         29 k
 sshpass                     x86_64        1.09-4.el9                       appstream         27 k

Transaction Summary
===================================================================================================
Install  19 Packages

Total download size: 16 M
Installed size: 77 M
Is this ok [y/N]: y
Downloading Packages:
(1/19): python3-pyyaml-5.4.1-6.el9.x86_64.rpm                      275 kB/s | 191 kB     00:00    
(2/19): python3-jinja2-2.11.3-4.el9.noarch.rpm                     328 kB/s | 229 kB     00:00    
(3/19): python3-packaging-20.9-5.el9.noarch.rpm                    554 kB/s |  69 kB     00:00    
(4/19): python3-resolvelib-0.5.4-5.el9.noarch.rpm                  304 kB/s |  29 kB     00:00    
(5/19): python3-pytz-2021.1-4.el9.noarch.rpm                       157 kB/s |  48 kB     00:00    
(6/19): python3-pycparser-2.20-6.el9.noarch.rpm                    724 kB/s | 124 kB     00:00    
(7/19): python3-ply-3.11-14.el9.noarch.rpm                         555 kB/s | 103 kB     00:00    
(8/19): python3-markupsafe-1.1.1-12.el9.x86_64.rpm                 321 kB/s |  32 kB     00:00    
(9/19): perl-Error-0.17029-7.el9.noarch.rpm                        372 kB/s |  41 kB     00:00    
(10/19): sshpass-1.09-4.el9.x86_64.rpm                             211 kB/s |  27 kB     00:00    
(11/19): python3-cffi-1.14.5-5.el9.x86_64.rpm                      692 kB/s | 241 kB     00:00    
(12/19): emacs-filesystem-27.2-6.el9.noarch.rpm                     57 kB/s | 8.4 kB     00:00    
(13/19): perl-Git-2.31.1-2.el9.2.noarch.rpm                        334 kB/s |  43 kB     00:00    
(14/19): python3-cryptography-36.0.1-1.el9_0.x86_64.rpm            916 kB/s | 1.1 MB     00:01    
(15/19): python3-babel-2.9.1-2.el9.noarch.rpm                      1.1 MB/s | 5.8 MB     00:05    
(16/19): git-core-doc-2.31.1-2.el9.2.noarch.rpm                    699 kB/s | 2.3 MB     00:03    
(17/19): git-2.31.1-2.el9.2.x86_64.rpm                             349 kB/s | 120 kB     00:00    
(18/19): git-core-2.31.1-2.el9.2.x86_64.rpm                        1.4 MB/s | 3.6 MB     00:02    
(19/19): ansible-core-2.12.2-1.el9.rocky.0.1.x86_64.rpm            1.7 MB/s | 2.0 MB     00:01    
---------------------------------------------------------------------------------------------------
Total                                                              2.2 MB/s |  16 MB     00:07     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                           1/1 
  Installing       : git-core-2.31.1-2.el9.2.x86_64                                           1/19 
  Installing       : git-core-doc-2.31.1-2.el9.2.noarch                                       2/19 
  Installing       : emacs-filesystem-1:27.2-6.el9.noarch                                     3/19 
  Installing       : sshpass-1.09-4.el9.x86_64                                                4/19 
  Installing       : perl-Error-1:0.17029-7.el9.noarch                                        5/19 
  Installing       : git-2.31.1-2.el9.2.x86_64                                                6/19 
  Installing       : perl-Git-2.31.1-2.el9.2.noarch                                           7/19 
  Installing       : python3-markupsafe-1.1.1-12.el9.x86_64                                   8/19 
  Installing       : python3-ply-3.11-14.el9.noarch                                           9/19 
  Installing       : python3-pycparser-2.20-6.el9.noarch                                     10/19 
  Installing       : python3-cffi-1.14.5-5.el9.x86_64                                        11/19 
  Installing       : python3-cryptography-36.0.1-1.el9_0.x86_64                              12/19 
  Installing       : python3-resolvelib-0.5.4-5.el9.noarch                                   13/19 
  Installing       : python3-packaging-20.9-5.el9.noarch                                     14/19 
  Installing       : python3-pytz-2021.1-4.el9.noarch                                        15/19 
  Installing       : python3-babel-2.9.1-2.el9.noarch                                        16/19 
  Installing       : python3-jinja2-2.11.3-4.el9.noarch                                      17/19 
  Installing       : python3-pyyaml-5.4.1-6.el9.x86_64                                       18/19 
  Installing       : ansible-core-2.12.2-1.el9.rocky.0.1.x86_64                              19/19 
  Running scriptlet: ansible-core-2.12.2-1.el9.rocky.0.1.x86_64                              19/19 
  Verifying        : python3-pyyaml-5.4.1-6.el9.x86_64                                        1/19 
  Verifying        : python3-babel-2.9.1-2.el9.noarch                                         2/19 
  Verifying        : python3-jinja2-2.11.3-4.el9.noarch                                       3/19 
  Verifying        : python3-pytz-2021.1-4.el9.noarch                                         4/19 
  Verifying        : python3-packaging-20.9-5.el9.noarch                                      5/19 
  Verifying        : python3-resolvelib-0.5.4-5.el9.noarch                                    6/19 
  Verifying        : python3-pycparser-2.20-6.el9.noarch                                      7/19 
  Verifying        : python3-ply-3.11-14.el9.noarch                                           8/19 
  Verifying        : python3-markupsafe-1.1.1-12.el9.x86_64                                   9/19 
  Verifying        : perl-Error-1:0.17029-7.el9.noarch                                       10/19 
  Verifying        : python3-cffi-1.14.5-5.el9.x86_64                                        11/19 
  Verifying        : sshpass-1.09-4.el9.x86_64                                               12/19 
  Verifying        : emacs-filesystem-1:27.2-6.el9.noarch                                    13/19 
  Verifying        : python3-cryptography-36.0.1-1.el9_0.x86_64                              14/19 
  Verifying        : perl-Git-2.31.1-2.el9.2.noarch                                          15/19 
  Verifying        : git-core-doc-2.31.1-2.el9.2.noarch                                      16/19 
  Verifying        : git-core-2.31.1-2.el9.2.x86_64                                          17/19 
  Verifying        : git-2.31.1-2.el9.2.x86_64                                               18/19 
  Verifying        : ansible-core-2.12.2-1.el9.rocky.0.1.x86_64                              19/19 

Installed:
  ansible-core-2.12.2-1.el9.rocky.0.1.x86_64       emacs-filesystem-1:27.2-6.el9.noarch            
  git-2.31.1-2.el9.2.x86_64                        git-core-2.31.1-2.el9.2.x86_64                  
  git-core-doc-2.31.1-2.el9.2.noarch               perl-Error-1:0.17029-7.el9.noarch               
  perl-Git-2.31.1-2.el9.2.noarch                   python3-babel-2.9.1-2.el9.noarch                
  python3-cffi-1.14.5-5.el9.x86_64                 python3-cryptography-36.0.1-1.el9_0.x86_64      
  python3-jinja2-2.11.3-4.el9.noarch               python3-markupsafe-1.1.1-12.el9.x86_64          
  python3-packaging-20.9-5.el9.noarch              python3-ply-3.11-14.el9.noarch                  
  python3-pycparser-2.20-6.el9.noarch              python3-pytz-2021.1-4.el9.noarch                
  python3-pyyaml-5.4.1-6.el9.x86_64                python3-resolvelib-0.5.4-5.el9.noarch           
  sshpass-1.09-4.el9.x86_64                       

Complete!
[root@rockylinux devops]# 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 = /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
[root@rockylinux devops]# dnf list ansible-core
Last metadata expiration check: 1:09:53 ago on Tue 19 Jul 2022 10:15:38 AM UTC.
Installed Packages
ansible-core.x86_64                        2.12.2-1.el9.rocky.0.1                        @appstream
[root@rockylinux devops]# dnf info ansible-core
Last metadata expiration check: 1:10:05 ago on Tue 19 Jul 2022 10:15:38 AM UTC.
Installed Packages
Name         : ansible-core
Version      : 2.12.2
Release      : 1.el9.rocky.0.1
Architecture : x86_64
Size         : 9.3 M
Source       : ansible-core-2.12.2-1.el9.rocky.0.1.src.rpm
Repository   : @System
From repo    : appstream
Summary      : SSH-based configuration management, deployment, and task execution system
URL          : http://ansible.com
License      : GPLv3+
Description  : Ansible is a radically simple model-driven configuration management,
             : multi-node deployment, and remote task execution system. Ansible works
             : over SSH and does not require any software or daemons to be installed
             : on remote nodes. Extension modules can be written in any language and
             : are transferred to managed machines automatically.

[root@rockylinux devops]#

before execution

[root@rockylinux devops]# dnf list ansible-core
Last metadata expiration check: 1:08:31 ago on Tue 19 Jul 2022 10:15:38 AM UTC.
Available Packages
ansible-core.x86_64                        2.12.2-1.el9.rocky.0.1                         appstream
[root@rockylinux devops]# dnf info ansible-core
Last metadata expiration check: 1:08:24 ago on Tue 19 Jul 2022 10:15:38 AM UTC.
Available Packages
Name         : ansible-core
Version      : 2.12.2
Release      : 1.el9.rocky.0.1
Architecture : x86_64
Size         : 2.0 M
Source       : ansible-core-2.12.2-1.el9.rocky.0.1.src.rpm
Repository   : appstream
Summary      : SSH-based configuration management, deployment, and task execution system
URL          : http://ansible.com
License      : GPLv3+
Description  : Ansible is a radically simple model-driven configuration management,
             : multi-node deployment, and remote task execution system. Ansible works
             : over SSH and does not require any software or daemons to be installed
             : on remote nodes. Extension modules can be written in any language and
             : are transferred to managed machines automatically.

[root@rockylinux devops]#

after execution

[root@rockylinux devops]# dnf list ansible-core
Last metadata expiration check: 1:09:53 ago on Tue 19 Jul 2022 10:15:38 AM UTC.
Installed Packages
ansible-core.x86_64                        2.12.2-1.el9.rocky.0.1                        @appstream
[root@rockylinux devops]# dnf info ansible-core
Last metadata expiration check: 1:10:05 ago on Tue 19 Jul 2022 10:15:38 AM UTC.
Installed Packages
Name         : ansible-core
Version      : 2.12.2
Release      : 1.el9.rocky.0.1
Architecture : x86_64
Size         : 9.3 M
Source       : ansible-core-2.12.2-1.el9.rocky.0.1.src.rpm
Repository   : @System
From repo    : appstream
Summary      : SSH-based configuration management, deployment, and task execution system
URL          : http://ansible.com
License      : GPLv3+
Description  : Ansible is a radically simple model-driven configuration management,
             : multi-node deployment, and remote task execution system. Ansible works
             : over SSH and does not require any software or daemons to be installed
             : on remote nodes. Extension modules can be written in any language and
             : are transferred to managed machines automatically.

[root@rockylinux devops]#

code with ❤️ in GitHub

Recap

Now you know how to install the latest version of Ansible in Rocky Linux using the AppStream repository. Subscribe to the YouTube channel, Medium, Website, Twitter, and Substack to not miss the next episode of the Ansible Pilot.

Academy

Learn the Ansible automation technology with some real-life examples in my

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

Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons
Follow me

Subscribe not to miss any new releases