You can install Ansible on a Red Hat Enterprise Linux (RHEL) system by using the EPEL (Extra Packages for Enterprise Linux) repository, which provides extra open-source software packages for enterprise Linux.
Here are the steps:
Step 1: Enable the EPEL Repository
First, you need to enable the EPEL repository. You can do this with the following command:
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Please adjust the above URL to match your RHEL version. For RHEL 8, use epel-release-latest-8.noarch.rpm
.
Step 2: Install Ansible
After the EPEL repository is enabled, you can install Ansible with the following command:
sudo yum install ansible
Step 3: Verify Installation
To verify that Ansible is installed correctly, you can check its version with the following command:
This command should return the version of Ansible that is currently installed.
This process should install Ansible on your RHEL system. From there, you can start creating playbooks and roles to automate your tasks.
Running the ansible --version
command in the command line provides you with the version of Ansible currently installed on your machine. The command also prints additional information, including the Python version used by Ansible, location of the Ansible executable, configuration and library locations, among others.
Here’s an example of the output you might see:
$ ansible --version ansible 2.9.6 config file = /etc/ansible/ansible.cfg configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python3.8/site-packages/ansible executable location = /usr/bin/ansible python version = 3.8.1 (default, Jan 22 2020, 06:38:00) [GCC 9.2.0]
In this example, the version of Ansible installed is 2.9.6, the configuration file is located at /etc/ansible/ansible.cfg, and the Python version used is 3.8.1.
Keep in mind that to use Ansible, you should have SSH access to the systems you plan to manage. Make sure you have SSH set up and working before you start working with Ansible.