How to Install Ansible Automation Tool on CentOS/RHEL 8

How to Install Ansible Automation Tool on CentOS/RHEL 8

Ansible is a free and open source automation tool that allows system administrators to configure and control hundreds of nodes from a central server without the need of installing any agents on the nodes.

It relies on the SSH protocol to communicate with the remote nodes. Compared to other management tools such as Puppet and Chef, Ansible comes out as the favorite due to its ease of use, and installation.

In this tutorial, you will learn how to install and configure the Ansible automation tool on RHEL/CentOS 8 Linux distribution.

Step 1: Installing Python3

Usually, RHEL 8 and CentOS 8 will come with Python3 already installed by default. However, If for whatever reason Python3 is not installed, install it using the following dnf commands. Make sure you must log in as normal user with sudo privileges.

su - aeterno
sudo dnf update
sudo dnf install python3

To verify that indeed you have python3 installed, run the command.

python3 -V

Step 2: Installing PIP – The Python Package Installer

Pip is a Python’s package manager, which is also comes preinstalled, but again, in case Pip is missing on your system, install it using the command.

sudo dnf install python3-pip

Step 3: Installing the Ansible Automation Tool

With all the prerequisites met, install ansible by running the command.

pip3 install ansible --user

To check the version of Ansible, run.

ansible --version

Step 4: Testing the Ansible Automation Tool

To test ansible, first ensure that ssh is up and running.

sudo systemctl status sshd

Next, we need to create the hosts file in the /etc/ansible directory to define host machines.

sudo mkdir /etc/ansible  
cd /etc/ansible
sudo touch hosts

The hosts the file will be the inventory where you will have all your remote nodes.

Now open hosts file with your favorite editor and define the remote node as shown.


Next, generate SSH keys from which we will copy the public key to the remote node.


To copy the generated SSH key to the remote node run the command.

ssh-copy-id [email protected]

Now use Ansible to ping the remote node as shown.

ansible -i /etc/ansible/hosts web -m ping  

We have managed to successfully install and test Ansible on RHEL/CentOS 8 Linux distribution. If you have any questions, do share with us in the comments section below.

Posted by Aryo Prakarsa

Aryo Prakarsa are the author and creator Mimata from Indonesia who founded Mimata back in September 9, 2019. He is passionate about all things tech and knows the Machine Learning, IoT, Micro Controller, and many others

Leave a Reply