Ansible Installation on RedHat8

Analytics Vidhya
Published in
4 min readAug 7, 2020

--

Introduction

Server automation now plays an essential role in systems administration, due to the disposable nature of modern application environments. Configuration Management tools such as Ansible are typically used to streamline the process of automating server setup by establishing standard procedures for new servers while also reducing human error associated with manual setups.

Ansible offers a simple architecture that doesn’t require special software to be installed on nodes. It also provides a robust set of features and built-in modules which facilitate writing automation scripts.

Ansible is the preferred configuration tool when it is compared with similar tools like Puppet, Chef, and Salt because it doesn’t need an agent and it works on SSH and python.

Ansible Lab Details

  • RHEL 8 server with internet connectivity.
  • One ansible node( either CLI or GUI).

Installation of Ansible

We are going to install Ansible using pip (python’s package manager), in that case, firstly we need to install python3 and its pip3 package.

sudo yum install python36 -y

After installing python3, check its version by running

python version

Now, installing Ansible using pip3.

pip3 install ansible
Ansible installation

After installation, check the version

ansible version

By this, our ansible is successfully installed.

How to Use the Ansible Automation Tool?

When we install Ansible using yum or dnf command then its configuration file, inventory file, and roles directory created automatically under /etc/ansible folder. But while using pip3 as installer we have to configure everything.

Firstly creating Ansible folder.

sudo mkdir /etc/ansible

Now creating an inventory file for storing IP’s.

vim /etc/ansible/myhost.txt
Host inventory

You can create any *.txt file but it should be in the /etc/ansible only.

Also, [web] by setting this, we create hostGroups under which we can put as many as IP we can. HostGroup are very necessary when we have to do a similar task in many host IP.

Here, ansible_ssh_user=**** to the user you want to connect and it password ansible_ssh_pass=***.

Checking the list of host IP.

list of IP

For having connected with node we will be using the ssh protocol.

sudo yum install sshpass -y

Now, creating the main configuration file of ansible from where it will come to know about its managed node.

vim /etc/ansible/ansible.cfg
configuration file

Finally, the whole configuration is done. For checking everything was correctly done.

ansible all -m pingor

ansible (node IP) -m ping
or ansible (nodehost) -m ping
final output

Note:- If using CLI managed node than you have to add one more command in the configuration file( /etc/ansible/ansible.cfg) .

host_key_checking = False

Conclusion

Automating your infrastructure setup can not only save you time, but it also helps to ensure that your servers will follow a standard configuration that can be customized to your needs. With the distributed nature of modern applications and the need for consistency between different staging environments, automation like this has become a central component in many teams’ development processes.

So, it was all, how to set up the Ansible in Redhat8( rhel8). So, do follow for more exciting articles in Ansible world.

Claps and Comments are most welcome.

Thank you.

--

--