How to install Ansible in CentOS Stream version 9. Today we’re going to talk about the easier way to install and maintain Ansible inside CentO Stream version 9 using the system AppStream repository. I’m Luca Berton and welcome to today’s episode of Ansible Pilot

How to install Ansible in CentOS Stream 9

  • ansible-core in system AppStream repository
  • use Extra Packages for Enterprise Linux - EPEL Next additional packages for CentOS Stream

The easier way to install and maintain Ansible inside CentOS Stream version 9 is using the system AppStream repository. Another way is to use the additional EPEL Next repository. This repository is maintained by the Fedora Special Interest Group and that manages a high-quality set of additional packages for CentOS Stream, similar to Extra Packages for Enterprise Linux (EPEL) additional packages target for Red Hat Enterprise Linux (RHEL), CentOS, and Scientific Linux (SL) and Oracle Linux (OL).

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

Join 50+ hours of courses in our exclusive community

Playbook

Install Ansible in CentOS Stream version 9 via AppStream system repository.

code

  • Install-Ansible-CentOS-Stream9.sh
#!/bin/bash
sudo dnf install ansible-core

execution

$ ssh [email protected]
[devops@centos-stream ~]$ sudo su
[root@centos-stream devops]# cat /etc/redhat-release 
CentOS Stream release 9
[root@centos-stream devops]# cat /etc/os-release 
NAME="CentOS Stream"
VERSION="9"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="9"
PLATFORM_ID="platform:el9"
PRETTY_NAME="CentOS Stream 9"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:9"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 9"
REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"
[root@centos-stream devops]# hostnamectl 
 Static hostname: centos-stream.example.com
       Icon name: computer-vm
         Chassis: vm
      Machine ID: 27ac33d81e2a400cbdaf6ae0b2b82e1d
         Boot ID: 4060493b76fc4cc680defa0ffe99af41
  Virtualization: oracle
Operating System: CentOS Stream 9                 
     CPE OS Name: cpe:/o:centos:centos:9
          Kernel: Linux 5.14.0-17.el9.x86_64
    Architecture: x86-64
 Hardware Vendor: innotek GmbH
  Hardware Model: VirtualBox
[root@centos-stream devops]# dnf search ansible
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
CentOS Stream 9 - BaseOS                                           1.2 MB/s | 1.6 MB     00:01    
CentOS Stream 9 - AppStream                                        2.7 MB/s | 8.8 MB     00:03    
Last metadata expiration check: 0:00:01 ago on Mon 06 Dec 2021 11:55:34 AM UTC.
================================= Name & Summary Matched: ansible =================================
ansible-collection-microsoft-sql.noarch : The Ansible collection for Microsoft SQL Server
                                        : management
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
[root@centos-stream devops]# dnf info ansible-core
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
Last metadata expiration check: 0:00:55 ago on Mon 06 Dec 2021 11:55:34 AM UTC.
Available Packages
Name         : ansible-core
Version      : 2.12.0
Release      : 1.el9
Architecture : x86_64
Size         : 2.4 M
Source       : ansible-core-2.12.0-1.el9.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@centos-stream devops]# dnf install ansible-core
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
Last metadata expiration check: 0:01:13 ago on Mon 06 Dec 2021 11:55:34 AM UTC.
Dependencies resolved.
===================================================================================================
 Package                       Architecture    Version                    Repository          Size
===================================================================================================
Installing:
 ansible-core                  x86_64          2.12.0-1.el9               appstream          2.4 M
Installing dependencies:
 emacs-filesystem              noarch          1:27.1-3.el9               appstream          9.2 k
 git                           x86_64          2.31.1-2.el9.2             appstream          124 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.5 M
 perl-Error                    noarch          1:0.17029-7.el9            appstream           42 k
 perl-Git                      noarch          2.31.1-2.el9.2             appstream           43 k
 python3-babel                 noarch          2.9.1-2.el9                appstream          6.0 M
 python3-cffi                  x86_64          1.14.5-4.el9               appstream          254 k
 python3-cryptography          x86_64          3.4.7-5.el9                appstream          780 k
 python3-jinja2                noarch          2.11.3-4.el9               appstream          249 k
 python3-markupsafe            x86_64          1.1.1-12.el9               appstream           35 k
 python3-packaging             noarch          20.9-4.el9                 appstream           78 k
 python3-ply                   noarch          3.11-13.el9                appstream          107 k
 python3-pycparser             noarch          2.20-5.el9                 appstream          135 k
 python3-pytz                  noarch          2021.1-4.el9               appstream           52 k
 python3-resolvelib            noarch          0.5.4-5.el9                appstream           34 k
 sshpass                       x86_64          1.09-4.el9                 appstream           28 k
Transaction Summary
===================================================================================================
Install  18 Packages
Total download size: 16 M
Installed size: 75 M
Is this ok [y/N]: y
Downloading Packages:
(1/18): emacs-filesystem-27.1-3.el9.noarch.rpm                      38 kB/s | 9.2 kB     00:00    
(2/18): git-2.31.1-2.el9.2.x86_64.rpm                              302 kB/s | 124 kB     00:00    
(3/18): git-core-2.31.1-2.el9.2.x86_64.rpm                         763 kB/s | 3.6 MB     00:04    
(4/18): perl-Error-0.17029-7.el9.noarch.rpm                        375 kB/s |  42 kB     00:00    
(5/18): ansible-core-2.12.0-1.el9.x86_64.rpm                       450 kB/s | 2.4 MB     00:05    
(6/18): perl-Git-2.31.1-2.el9.2.noarch.rpm                         182 kB/s |  43 kB     00:00    
(7/18): python3-cffi-1.14.5-4.el9.x86_64.rpm                       655 kB/s | 254 kB     00:00    
(8/18): git-core-doc-2.31.1-2.el9.2.noarch.rpm                     473 kB/s | 2.5 MB     00:05    
(9/18): python3-jinja2-2.11.3-4.el9.noarch.rpm                     410 kB/s | 249 kB     00:00    
(10/18): python3-markupsafe-1.1.1-12.el9.x86_64.rpm                194 kB/s |  35 kB     00:00    
(11/18): python3-packaging-20.9-4.el9.noarch.rpm                   321 kB/s |  78 kB     00:00    
(12/18): python3-cryptography-3.4.7-5.el9.x86_64.rpm               640 kB/s | 780 kB     00:01    
(13/18): python3-ply-3.11-13.el9.noarch.rpm                        397 kB/s | 107 kB     00:00    
(14/18): python3-pycparser-2.20-5.el9.noarch.rpm                   533 kB/s | 135 kB     00:00    
(15/18): python3-pytz-2021.1-4.el9.noarch.rpm                      313 kB/s |  52 kB     00:00    
(16/18): sshpass-1.09-4.el9.x86_64.rpm                             236 kB/s |  28 kB     00:00    
(17/18): python3-resolvelib-0.5.4-5.el9.noarch.rpm                 236 kB/s |  34 kB     00:00    
(18/18): python3-babel-2.9.1-2.el9.noarch.rpm                      730 kB/s | 6.0 MB     00:08    
---------------------------------------------------------------------------------------------------
Total                                                              1.2 MB/s |  16 MB     00:14     
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/18 
  Installing       : git-core-doc-2.31.1-2.el9.2.noarch                                       2/18 
  Installing       : sshpass-1.09-4.el9.x86_64                                                3/18 
  Installing       : python3-resolvelib-0.5.4-5.el9.noarch                                    4/18 
  Installing       : python3-pytz-2021.1-4.el9.noarch                                         5/18 
  Installing       : python3-babel-2.9.1-2.el9.noarch                                         6/18 
  Installing       : python3-ply-3.11-13.el9.noarch                                           7/18 
  Installing       : python3-pycparser-2.20-5.el9.noarch                                      8/18 
  Installing       : python3-cffi-1.14.5-4.el9.x86_64                                         9/18 
  Installing       : python3-cryptography-3.4.7-5.el9.x86_64                                 10/18 
  Installing       : python3-packaging-20.9-4.el9.noarch                                     11/18 
  Installing       : python3-markupsafe-1.1.1-12.el9.x86_64                                  12/18 
  Installing       : python3-jinja2-2.11.3-4.el9.noarch                                      13/18 
  Installing       : perl-Error-1:0.17029-7.el9.noarch                                       14/18 
  Installing       : emacs-filesystem-1:27.1-3.el9.noarch                                    15/18 
  Installing       : perl-Git-2.31.1-2.el9.2.noarch                                          16/18 
  Installing       : git-2.31.1-2.el9.2.x86_64                                               17/18 
  Installing       : ansible-core-2.12.0-1.el9.x86_64                                        18/18 
  Running scriptlet: ansible-core-2.12.0-1.el9.x86_64                                        18/18 
  Verifying        : ansible-core-2.12.0-1.el9.x86_64                                         1/18 
  Verifying        : emacs-filesystem-1:27.1-3.el9.noarch                                     2/18 
  Verifying        : git-2.31.1-2.el9.2.x86_64                                                3/18 
  Verifying        : git-core-2.31.1-2.el9.2.x86_64                                           4/18 
  Verifying        : git-core-doc-2.31.1-2.el9.2.noarch                                       5/18 
  Verifying        : perl-Error-1:0.17029-7.el9.noarch                                        6/18 
  Verifying        : perl-Git-2.31.1-2.el9.2.noarch                                           7/18 
  Verifying        : python3-babel-2.9.1-2.el9.noarch                                         8/18 
  Verifying        : python3-cffi-1.14.5-4.el9.x86_64                                         9/18 
  Verifying        : python3-cryptography-3.4.7-5.el9.x86_64                                 10/18 
  Verifying        : python3-jinja2-2.11.3-4.el9.noarch                                      11/18 
  Verifying        : python3-markupsafe-1.1.1-12.el9.x86_64                                  12/18 
  Verifying        : python3-packaging-20.9-4.el9.noarch                                     13/18 
  Verifying        : python3-ply-3.11-13.el9.noarch                                          14/18 
  Verifying        : python3-pycparser-2.20-5.el9.noarch                                     15/18 
  Verifying        : python3-pytz-2021.1-4.el9.noarch                                        16/18 
  Verifying        : python3-resolvelib-0.5.4-5.el9.noarch                                   17/18 
  Verifying        : sshpass-1.09-4.el9.x86_64                                               18/18 
Installed products updated.
Installed:
  ansible-core-2.12.0-1.el9.x86_64                emacs-filesystem-1:27.1-3.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-4.el9.x86_64                python3-cryptography-3.4.7-5.el9.x86_64          
  python3-jinja2-2.11.3-4.el9.noarch              python3-markupsafe-1.1.1-12.el9.x86_64           
  python3-packaging-20.9-4.el9.noarch             python3-ply-3.11-13.el9.noarch                   
  python3-pycparser-2.20-5.el9.noarch             python3-pytz-2021.1-4.el9.noarch                 
  python3-resolvelib-0.5.4-5.el9.noarch           sshpass-1.09-4.el9.x86_64
Complete!
[root@centos-stream devops]# ansible --version
ansible [core 2.12.0]
  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.8 (main, Nov  8 2021, 00:00:00) [GCC 11.2.1 20211019 (Red Hat 11.2.1-6)]
  jinja version = 2.11.3
  libyaml = True
[root@centos-stream devops]# dnf info ansible-core
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
Last metadata expiration check: 0:02:00 ago on Mon 06 Dec 2021 11:55:34 AM UTC.
Installed Packages
Name         : ansible-core
Version      : 2.12.0
Release      : 1.el9
Architecture : x86_64
Size         : 9.3 M
Source       : ansible-core-2.12.0-1.el9.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@centos-stream devops]#

before execution

# dnf info ansible-core
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
Last metadata expiration check: 0:00:55 ago on Mon 06 Dec 2021 11:55:34 AM UTC.
Available Packages
Name         : ansible-core
Version      : 2.12.0
Release      : 1.el9
Architecture : x86_64
Size         : 2.4 M
Source       : ansible-core-2.12.0-1.el9.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@centos-stream devops]#

after execution

# dnf info ansible-core
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
Last metadata expiration check: 0:02:00 ago on Mon 06 Dec 2021 11:55:34 AM UTC.
Installed Packages
Name         : ansible-core
Version      : 2.12.0
Release      : 1.el9
Architecture : x86_64
Size         : 9.3 M
Source       : ansible-core-2.12.0-1.el9.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@centos-stream devops]#

code with ❤️ in GitHub

Conclusion

Now you know how to install the latest version of Ansible in CentOS Stream using the system AppStream repository. 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