Here is how to install Ansible on RHEL 9. Tested and verified.
Prerequisites
- RHEL 9 installed, registered with Red Hat Subscription Manager, and updated
- Root or sudo access
- Internet connection
Step 1: Update System
sudo dnf update -yStep 2: Enable the EPEL Repository
Ansible isn’t in RHEL’s base or AppStream repositories — it’s distributed through the community-maintained EPEL (Extra Packages for Enterprise Linux) repository. Enable the CodeReady Builder repository first, since several EPEL packages depend on it, then install the EPEL release package:
# Enable the CodeReady Builder repository
sudo subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms
# Install the EPEL release package
sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpmNote: on Rocky Linux, AlmaLinux, and other RHEL rebuilds, epel-release is already available directly via sudo dnf install -y epel-release — see Install Ansible on Rocky Linux 9. True RHEL needs the extra steps above because EPEL isn’t enabled by an active subscription by default.
Step 3: Install Ansible
sudo dnf install -y ansible-coreOr install the “batteries included” package with bundled community collections:
sudo dnf install -y ansibleStep 4: Verify Installation
ansible --version
ansible localhost -m pingExpected output shows the installed version, followed by a "ping": "pong" response.
Step 5: Verify Collections and Configuration
# List installed collections
ansible-galaxy collection list
# Install additional collections as needed
ansible-galaxy collection install community.general
ansible-galaxy collection install redhat.rhel_system_roles
# Inspect the active configuration
ansible-config viewAnsible is agentless and has no daemon or background service — it connects to managed hosts over SSH only when you run a command or playbook, so there is nothing to systemctl enable or check with systemctl status.
Alternative: pip Installation
sudo dnf install -y python3-pip
pip3 install ansible --user
echo 'export PATH=$PATH:$HOME/.local/bin' >> ~/.bashrc
source ~/.bashrcThis avoids EPEL entirely and is useful when you can’t enable third-party repositories on a locked-down RHEL host. For a fully isolated setup, see Install Ansible with pip in a Virtual Environment.
Troubleshooting
Package Not Found
Confirm EPEL is actually enabled before installing:
sudo dnf clean all && sudo dnf makecache
dnf repolist | grep -i epelSubscription / Entitlement Errors
If subscription-manager repos --enable ... fails with a message like “This system is not registered” or “Unable to find available repositories,” your host isn’t registered or attached to a subscription yet:
sudo subscription-manager register
sudo subscription-manager attach --autoUninstall
sudo dnf remove -y ansible ansible-coreRelated Guides
About the Author
I am Luca Berton, AI and Cloud Advisor. Book a consultation to get help with your infrastructure setup.