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.

Sandclock IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, Sandclock IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

CentOS8 Release Date and Features

CentOS Logo Red Hat released RHEL version 8.0 on May 7, 2019 so lots of folks are looking where is the equivalent build...

Install Google Chrome on RHEL8

This tutorial explains how to install Google Chrome with 2 commands only (wget and yum install) as an introduction to packages...

Understanding Red Hat Linux Price and Pricing

Despite being around for two decades and being one of the most popular Linux server distributions, the pricing of Red Hat...
Bài Viết

Bài Viết Mới Cập Nhật

Hướng dẫn chuyển đổi windows server windows evaluation to standard và active windows server 2008 + 2012 + 2016 + 2019

How to Update Ubuntu Linux

Squid Proxy Manager cài đặt và quản lý Proxy Squid tự động trên ubuntu

Hướng dẫn cài đặt Apache CloudStack

Hướng dẫn ký file PDF bằng chữ ký số (chữ ký điện tử) và sửa lỗi mới nhất 2021 foxit reader