AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

How to install Ansible in CentOS 8 Stream - Ansible install

By Luca Berton · Published 2024-01-01 · Category: installation

Learn the easiest way to install and maintain Ansible on CentOS Stream 8 using the EPEL Next repository, managed by the Fedora Special Interest Group.

How to install Ansible in CentOS 8 Stream - Ansible install

How to install Ansible in CentOS Stream version 8. Today we're going to talk about the easier way to install and maintain Ansible inside CentOS Stream 8 using the EPEL Next repository. I'm Luca Berton and welcome to today's episode of Ansible Pilot

How to install Ansible in CentOS Stream 8

• 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 8 is using the Extra Packages for Enterprise Linux (EPEL) Next additional repository. This repository is maintained by the Fedora Special Interest Group and manages a high-quality set of additional packages for CentOS Stream. It's very similar to Extra Packages for Enterprise Linux (EPEL) additional packages target for Red Hat Enterprise Linux (RHEL), CentOS, Scientific Linux (SL), and Oracle Linux (OL).

## Playbook

Let's jump in a quick live Playbook of how to install Ansible in CentOS Stream version 8.

code

• install-Ansible-CentOS-Stream8.sh
#!/bin/bash
$ sudo yum install epel-next-release
$ sudo yum install ansible

execution

output
# cat /etc/redhat-release 
CentOS Stream release 8
# yum install epel-next-release
Last metadata expiration check: 0:17:42 ago on Tue 19 Oct 2021 08:38:09 AM UTC.
Dependencies resolved.
===================================================================================================
 Package                       Architecture       Version                 Repository          Size
===================================================================================================
Installing:
 epel-next-release             noarch             8-11.el8                extras              11 k
Installing dependencies:
 epel-release                  noarch             8-11.el8                extras              24 k
Transaction Summary
===================================================================================================
Install  2 Packages
Total download size: 35 k
Installed size: 38 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): epel-release-8-11.el8.noarch.rpm                            398 kB/s |  24 kB     00:00    
(2/2): epel-next-release-8-11.el8.noarch.rpm                        57 kB/s |  11 kB     00:00    
---------------------------------------------------------------------------------------------------
Total                                                              108 kB/s |  35 kB     00:00     
warning: /var/cache/dnf/extras-4caecf8d6e840d19/packages/epel-next-release-8-11.el8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY
CentOS Stream 8 - Extras                                           1.6 MB/s | 1.6 kB     00:00    
Importing GPG key 0x8483C65D:
 Userid     : "CentOS (CentOS Official Signing Key) <security@centos.org>"
 Fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                           1/1 
  Installing       : epel-release-8-11.el8.noarch                                              1/2 
  Installing       : epel-next-release-8-11.el8.noarch                                         2/2 
  Running scriptlet: epel-next-release-8-11.el8.noarch                                         2/2 
  Verifying        : epel-next-release-8-11.el8.noarch                                         1/2 
  Verifying        : epel-release-8-11.el8.noarch                                              2/2
Installed:
  epel-next-release-8-11.el8.noarch                  epel-release-8-11.el8.noarch
Complete!
# yum install ansible
Extra Packages for Enterprise Linux Modular 8 - x86_64             939 kB/s | 955 kB     00:01    
Extra Packages for Enterprise Linux 8 - Next - x86_64              2.7 MB/s | 1.3 MB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                     3.8 MB/s |  10 MB     00:02    
Dependencies resolved.
===================================================================================================
 Package                  Arch       Version                                   Repository     Size
===================================================================================================
Installing:
 ansible                  noarch     2.9.25-1.el8                              epel           17 M
Installing dependencies:
 libsodium                x86_64     1.0.18-2.el8                              epel          162 k
 python3-babel            noarch     2.5.1-7.el8                               appstream     4.8 M
 python3-bcrypt           x86_64     3.1.6-2.el8.1                             epel           44 k
 python3-cffi             x86_64     1.11.5-5.el8                              baseos        237 k
 python3-cryptography     x86_64     3.2.1-5.el8                               baseos        559 k
 python3-jinja2           noarch     2.10.1-3.el8                              appstream     538 k
 python3-jmespath         noarch     0.9.0-11.el8                              appstream      45 k
 python3-markupsafe       x86_64     0.23-19.el8                               appstream      39 k
 python3-pip              noarch     9.0.3-19.el8                              appstream      20 k
 python3-ply              noarch     3.9-9.el8                                 baseos        111 k
 python3-pyasn1           noarch     0.3.7-6.el8                               appstream     126 k
 python3-pycparser        noarch     2.14-14.el8                               baseos        109 k
 python3-pynacl           x86_64     1.3.0-5.el8                               epel          100 k
 python3-pytz             noarch     2017.2-9.el8                              appstream      54 k
 python3-setuptools       noarch     39.2.0-6.el8                              baseos        163 k
 python36                 x86_64     3.6.8-37.module_el8.5.0+771+e5d9a225      appstream      19 k
 sshpass                  x86_64     1.06-9.el8                                epel           27 k
Installing weak dependencies:
 python3-paramiko         noarch     2.4.3-1.el8                               epel          289 k
Enabling module streams:
 python36                            3.6
Transaction Summary
===================================================================================================
Install  19 Packages
Total download size: 24 M
Installed size: 127 M
Is this ok [y/N]: y
Downloading Packages:
(1/19): python3-jmespath-0.9.0-11.el8.noarch.rpm                   507 kB/s |  45 kB     00:00    
(2/19): python3-markupsafe-0.23-19.el8.x86_64.rpm                  848 kB/s |  39 kB     00:00    
(3/19): python3-jinja2-2.10.1-3.el8.noarch.rpm                     2.0 MB/s | 538 kB     00:00    
(4/19): python3-pip-9.0.3-19.el8.noarch.rpm                        148 kB/s |  20 kB     00:00    
(5/19): python3-pytz-2017.2-9.el8.noarch.rpm                       1.5 MB/s |  54 kB     00:00    
(6/19): python3-pyasn1-0.3.7-6.el8.noarch.rpm                      2.0 MB/s | 126 kB     00:00    
(7/19): python36-3.6.8-37.module_el8.5.0+771+e5d9a225.x86_64.rpm   728 kB/s |  19 kB     00:00    
(8/19): python3-cryptography-3.2.1-5.el8.x86_64.rpm                2.6 MB/s | 559 kB     00:00    
(9/19): python3-cffi-1.11.5-5.el8.x86_64.rpm                       1.0 MB/s | 237 kB     00:00    
(10/19): python3-ply-3.9-9.el8.noarch.rpm                          2.6 MB/s | 111 kB     00:00    
(11/19): python3-setuptools-39.2.0-6.el8.noarch.rpm                3.3 MB/s | 163 kB     00:00    
(12/19): python3-pycparser-2.14-14.el8.noarch.rpm                  1.0 MB/s | 109 kB     00:00    
(13/19): libsodium-1.0.18-2.el8.x86_64.rpm                         1.6 MB/s | 162 kB     00:00    
(14/19): python3-bcrypt-3.1.6-2.el8.1.x86_64.rpm                   1.0 MB/s |  44 kB     00:00    
(15/19): python3-paramiko-2.4.3-1.el8.noarch.rpm                   1.8 MB/s | 289 kB     00:00    
(16/19): python3-pynacl-1.3.0-5.el8.x86_64.rpm                     1.3 MB/s | 100 kB     00:00    
(17/19): sshpass-1.06-9.el8.x86_64.rpm                             1.2 MB/s |  27 kB     00:00    
(18/19): python3-babel-2.5.1-7.el8.noarch.rpm                      2.3 MB/s | 4.8 MB     00:02    
(19/19): ansible-2.9.25-1.el8.noarch.rpm                           4.5 MB/s |  17 MB     00:03    
---------------------------------------------------------------------------------------------------
Total                                                              4.8 MB/s |  24 MB     00:05     
warning: /var/cache/dnf/epel-6c12381928511f32/packages/ansible-2.9.25-1.el8.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 2f86d6a1: NOKEY
Extra Packages for Enterprise Linux 8 - x86_64                     1.6 MB/s | 1.6 kB     00:00    
Importing GPG key 0x2F86D6A1:
 Userid     : "Fedora EPEL (8) <epel@fedoraproject.org>"
 Fingerprint: 94E2 79EB 8D8F 25B2 1810 ADF1 21EA 45AB 2F86 D6A1
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                           1/1 
  Installing       : python3-setuptools-39.2.0-6.el8.noarch                                   1/19 
  Installing       : python36-3.6.8-37.module_el8.5.0+771+e5d9a225.x86_64                     2/19 
  Running scriptlet: python36-3.6.8-37.module_el8.5.0+771+e5d9a225.x86_64                     2/19 
  Installing       : python3-pip-9.0.3-19.el8.noarch                                          3/19 
  Installing       : sshpass-1.06-9.el8.x86_64                                                4/19 
  Installing       : libsodium-1.0.18-2.el8.x86_64                                            5/19 
  Installing       : python3-ply-3.9-9.el8.noarch                                             6/19 
  Installing       : python3-pycparser-2.14-14.el8.noarch                                     7/19 
  Installing       : python3-cffi-1.11.5-5.el8.x86_64                                         8/19 
  Installing       : python3-cryptography-3.2.1-5.el8.x86_64                                  9/19 
  Installing       : python3-bcrypt-3.1.6-2.el8.1.x86_64                                     10/19 
  Installing       : python3-pynacl-1.3.0-5.el8.x86_64                                       11/19 
  Installing       : python3-pytz-2017.2-9.el8.noarch                                        12/19 
  Installing       : python3-babel-2.5.1-7.el8.noarch                                        13/19 
  Installing       : python3-pyasn1-0.3.7-6.el8.noarch                                       14/19 
  Installing       : python3-paramiko-2.4.3-1.el8.noarch                                     15/19 
  Installing       : python3-markupsafe-0.23-19.el8.x86_64                                   16/19 
  Installing       : python3-jinja2-2.10.1-3.el8.noarch                                      17/19 
  Installing       : python3-jmespath-0.9.0-11.el8.noarch                                    18/19 
  Installing       : ansible-2.9.25-1.el8.noarch                                             19/19 
  Running scriptlet: ansible-2.9.25-1.el8.noarch                                             19/19 
  Verifying        : python3-babel-2.5.1-7.el8.noarch                                         1/19 
  Verifying        : python3-jinja2-2.10.1-3.el8.noarch                                       2/19 
  Verifying        : python3-jmespath-0.9.0-11.el8.noarch                                     3/19 
  Verifying        : python3-markupsafe-0.23-19.el8.x86_64                                    4/19 
  Verifying        : python3-pip-9.0.3-19.el8.noarch                                          5/19 
  Verifying        : python3-pyasn1-0.3.7-6.el8.noarch                                        6/19 
  Verifying        : python3-pytz-2017.2-9.el8.noarch                                         7/19 
  Verifying        : python36-3.6.8-37.module_el8.5.0+771+e5d9a225.x86_64                     8/19 
  Verifying        : python3-cffi-1.11.5-5.el8.x86_64                                         9/19 
  Verifying        : python3-cryptography-3.2.1-5.el8.x86_64                                 10/19 
  Verifying        : python3-ply-3.9-9.el8.noarch                                            11/19 
  Verifying        : python3-pycparser-2.14-14.el8.noarch                                    12/19 
  Verifying        : python3-setuptools-39.2.0-6.el8.noarch                                  13/19 
  Verifying        : ansible-2.9.25-1.el8.noarch                                             14/19 
  Verifying        : libsodium-1.0.18-2.el8.x86_64                                           15/19 
  Verifying        : python3-bcrypt-3.1.6-2.el8.1.x86_64                                     16/19 
  Verifying        : python3-paramiko-2.4.3-1.el8.noarch                                     17/19 
  Verifying        : python3-pynacl-1.3.0-5.el8.x86_64                                       18/19 
  Verifying        : sshpass-1.06-9.el8.x86_64                                               19/19
Installed:
  ansible-2.9.25-1.el8.noarch               libsodium-1.0.18-2.el8.x86_64                          
  python3-babel-2.5.1-7.el8.noarch          python3-bcrypt-3.1.6-2.el8.1.x86_64                    
  python3-cffi-1.11.5-5.el8.x86_64          python3-cryptography-3.2.1-5.el8.x86_64                
  python3-jinja2-2.10.1-3.el8.noarch        python3-jmespath-0.9.0-11.el8.noarch                   
  python3-markupsafe-0.23-19.el8.x86_64     python3-paramiko-2.4.3-1.el8.noarch                    
  python3-pip-9.0.3-19.el8.noarch           python3-ply-3.9-9.el8.noarch                           
  python3-pyasn1-0.3.7-6.el8.noarch         python3-pycparser-2.14-14.el8.noarch                   
  python3-pynacl-1.3.0-5.el8.x86_64         python3-pytz-2017.2-9.el8.noarch                       
  python3-setuptools-39.2.0-6.el8.noarch    python36-3.6.8-37.module_el8.5.0+771+e5d9a225.x86_64   
  sshpass-1.06-9.el8.x86_64
Complete!
[root@centos-stream devops]# ansible --version
ansible 2.9.25
  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 = /bin/ansible
  python version = 3.6.8 (default, Jan 27 2021, 01:17:18) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]

code with ❤️ in GitHub

See also: How to install Ansible in CentOS 9 Stream - Ansible install

Conclusion

Now you know how to install the latest version of Ansible in CentOS Stream using the EPEL Next repository.

Related Articles

Jinja2 filters in Ansible templates

See also: How to install Ansible in AlmaLinux 9 - Ansible install

Post-Installation Setup

After installing Ansible on CentOS 8 Stream, configure your environment:

# Verify installation
ansible --version

# Create inventory file mkdir -p ~/ansible cat > ~/ansible/inventory.ini << EOF [local] localhost ansible_connection=local

[webservers] # Add your servers here # web01 ansible_host=192.168.1.10 EOF

# Create ansible.cfg cat > ~/ansible/ansible.cfg << EOF [defaults] inventory = ~/ansible/inventory.ini remote_user = ansible host_key_checking = False

[privilege_escalation] become = True become_method = sudo EOF

# Test connection ansible localhost -m ansible.builtin.ping

CentOS 8 Stream End of Life Notice

> Important: CentOS 8 Stream reached end of life on May 31, 2024. Consider migrating to: > - CentOS Stream 9 — latest CentOS Stream release > - AlmaLinux 9 or Rocky Linux 9 — RHEL-compatible alternatives > - RHEL 9 — with free developer subscription

See also: How to install Ansible in CentOS 8 - Ansible install

Installing via pip (Alternative)

# Install pip
sudo dnf install -y python3-pip

# Install Ansible python3 -m pip install --user ansible

# Add to PATH if needed echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc source ~/.bashrc

FAQ

Is CentOS 8 Stream still supported?

No. CentOS 8 Stream reached end of life on May 31, 2024. Migrate to CentOS Stream 9, AlmaLinux 9, Rocky Linux 9, or RHEL 9.

Which Ansible version is available via EPEL on CentOS 8 Stream?

EPEL for CentOS 8 provides ansible-core. For the latest version, use pip.

Can I run Ansible from CentOS 8 Stream to manage other OS versions?

Yes. Ansible runs on the control node (CentOS 8 Stream) and manages remote hosts running any supported OS via SSH.

Should I migrate to CentOS Stream 9?

Yes, if you want to stay on the CentOS track. CentOS Stream 9 is actively maintained and has ansible-core in AppStream.

Category: installation

Watch the video: How to install Ansible in CentOS 8 Stream - Ansible install — Video Tutorial

Browse all Ansible tutorials · AnsiblePilot Home