Install and configure Ansible automation on RHEL 8

Ansible is the leading free and opensource configuration management, automation tool. With Ansible, Linux users can control and manage hundreds of servers from a single server known as the Ansible Control Node. Ansible makes it possible for System and Network administrators to provision software and settings on various network devices. Ansible can be used to manage both Unix and Windows host systems. Ansible was initially released 7 years ago. The latest stable version at the point of writing this article is Ansible 2.8.5.Unlike many other automation tools such as Chef and Puppet, Ansible does not require the installation of agents on remote devices. Ansible rides on SSH protocol to communicate with remote host systems. Without the need of installing agents on remote systems, Ansible comes highly recommended since very little CPU and RAM resources are used up by remote systems. In this guide, you will learn how to install and configure Ansible on RHEL 8


To get started, we have a lab setup as shown:

  1. RHEL 8 (Ansible Control Node) IP:
  2. Ubuntu 18.04 Server (Managed host) IP:
  3. A stable internet and network connection

The RHEL 8 system will serve as our Ansible Control node, from where we will connect to and manage the remote Ubuntu 18.04 Server.

Install Ansible on RHEL 8

Let’s jump right in!

Step 1: Update RHEL 8

To install Ansible, first log in to your system and update the system packages using the command:

# sudo dnf update -y

Sample output

After successfully updating the system, you should get the prompt below

Step 2: Install Python3 on RHEL 8

By default, RHEL 8 comes with Python3 installed. If by any chance Python3 is missing from your system, simply run the command:

# sudo dnf install python3

As you can see from the output above, Python3 is already installed. To verify its installation, run the command:

# python3 -V

Sample output

From the output above, the latest version of Python – 3.6.8 – is installed by default.

Step 3: Install Ansible

With the prerequisites in check, now proceed and install Ansible using the commands:

$ subscription-manager repos --enable ansible-2.8-for-rhel-8-x86_64-rpms

Sample output

Next, run the command below to install Ansible:

$ sudo  dnf -y install ansible

Sample output

After successful installation, you should get the following output:

To check Ansible version simply use the command:

# ansible --version

Ansible’s configuration file is ansible.cfg located at /etc/ansible/ansible.cfg. 

Great! we have successfully installed Ansible on RHEL 8.

In the next section, we shall configure our Ansible Control node to communicate with and manage the remote Ubuntu 18.04 server system.

Step 4: Configure Passwordless SSH connection to the remote host

To efficiently manage our remote node, we need to configure Passwordless SSH login to it.

First, let’s check whether SSH is up and running on the Ansible Control. Run the command:

# sudo systemctl status sshd

Sample output

Great! SSH service is up and running as expected. Verify the same on the remote Ubuntu server host.

With SSH running on both systems, let’s configure passwordless SSH login from the control node to the remote host.

From the Ansible control node (RHEL 8) generate SSH keys as shown:

# ssh-keygen

Press ENTER for all the prompts. You should get the output as shown:

Sample output

The command generates an SSH key-pair i.e Private and Public key. The private key resides on the Ansible control node while the public key is copied to the managed node. To copy the public key to the managed node run the command:

# ssh-copy-id james@

To continue, type Yes and provided the user’s login password.

Thereafter, you will get the notification that the key has been added.

Sample output

To verify that the Password less login was a success, try logging in using the syntax

# ssh user@remote-IP address

For this case, the command will be:

# ssh james@

Step 5: Configure Ansible to communicate with Hosts

For Ansible to control and manage remote hosts, we need to define the remote host system in Ansible’s inventory file located at /etc/ansible/hosts.

So, proceed and open the ‘hosts’ inventory file using vim editor

# vim /etc/ansible/hosts

At the very end of the inventory file, specify an arbitrary group name for your host system and add the host’s IP address. For example, webserver is the group name and the IP address defined is the IP address of the remote host.


Save and close the inventory file.

We’re now set to manage our host system. To test connectivity using the ping module , run the Ansible adhoc command as shown.

# ansible -m ping webserver
# ansible -m ping

Sample output

If there were hundreds or even thousands of servers, we would use the ping module with the all attribute to test connectivity to the systems using a single command.

# ansible -m ping all

And this wraps up this topic on Installing and configuring Ansible automation tool. We have installed Ansible and set it up to manage the remote host system. Your feedback is most welcome.

About the author

James Kiarie

Hey there, this is James Kiarie, a certified Linux administrator with over 4 years of experience in the installation and configuration of Linux servers. Additionally, I have over 2 years in penning down high-quality technical articles in Linux, Windows and tech gadgets. In my free time, catch me listening to music, biking, swimming and playing video games.