Ansible installation¶
Ansible is an open-source agentless tool that facilitates the automation of software deployment. A supported version of Ansible (version 9 or later) can be installed via pip into a Python virtual environment. This guide assumes that pip and Python have been installed on the users' machines. The streamlined instructions for the installation of Ansible are provided below.
Ansible Package vs ansible-core
When you install Ansible via pip, you're installing the Ansible package which includes ansible-core plus additional modules. The version numbers differ:
- Ansible package 11.x includes ansible-core 2.18.x
- Ansible package 10.x includes ansible-core 2.17.x
- Ansible package 9.x includes ansible-core 2.16.x
Our playbooks check for ansible-core 2.16 or higher, which corresponds to Ansible package 9.0.1 or later.
Danger
If deploying to a target host that uses Python 3.6 bound to its package
manager (e.g., dnf
with RHEL 8), the latest version of Ansible that can
be installed is version 9. This limitation arises because the
ansible.builtin.package
module relies on package manager bindings to
the default OS Python version, which is Python 3.6 in RHEL 8. Ansible 10
and later require Python 3.7 or higher (see ansible-core
2.17 release notes).
If using RHEL 9, the latest version of Ansible can be used.
Installation into a Python Virtual Environment¶
The installations below are recommended to be done in a Python virtual environment to accommodate different versions of the software, if any.
Note
Sudo access is optional for the following commands as the installation can be done as the installation user in a Python virtual environment.
-
Create a Python 3 virtual environment.
python3 -m venv venv
-
Activate the virtual environment.
source venv/bin/activate
-
Upgrade pip and setuptools.
pip install --upgrade pip setuptools
-
Install Ansible.
pip install --upgrade ansible
To verify the installation and check versions:
# Check Ansible package version ansible --version # This will show ansible-core version (e.g., 2.18.x for Ansible 11.x) # Check installed package version pip show ansible # This will show the Ansible package version (e.g., 11.7.0)
The installation of Ansible can also be performed by following the steps outlined in the Ansible documentation.