Install & Configure Ansible in RHEL 8 (CentOS 8) | Ansible Configuration in Linux | Nehra Classes



Install & Configure Ansible in RHEL 8 (CentOS 8) | Ansible Configuration in Linux | Nehra Classes

Install & Configure Ansible in RHEL 8 (CentOS 8) | Ansible Configuration in Linux | Nehra Classes

Install & Configure Ansible in RHEL 8 (CentOS 8):
=================================================
Ansible is an open-source software provisioning, configuration management and application-deployment tool enabling infrastructure as code. It runs on many Unix-like systems, and can configure both Unix-like systems as well as Microsoft Windows.
It includes its own declarative language to describe system configuration.
Ansible was written by Michael DeHaan and acquired by Red Hat in 2015. Ansible is agentless, temporarily connecting remotely via SSH or Windows Remote Management (allowing remote PowerShell execution)
to do its tasks.

On RHEL 8, enable the official Red Hat repository, for the corresponding Ansible version that you want to install as shown in this article. DO NOT USE PIP ON RHEL 8!.

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.
# visudo
vikasnehra
# su – vikasnehra
$ 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 on CentOS 8.
# pip3 install ansible –user

On RHEL 8, enable the Ansible Engine repository to install corresponding Ansible version as shown,
# subscription-manager repos –enable ansible-2.8-for-rhel-8-x86_64-rpms
# dnf -y install ansible

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 vim 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.
[web]
192.168.1.109

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

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.
===
Thanks for watching the video. If it helped you then, please do like & share it with others as well. Feel free to post your queries & suggestions, we will be glad to answer your queries.
If you like our hard work then do subscribe to our channel & turn on the bell notification for latest updates.
===
Contact Us:
Vikas Nehra’s Twitter Handle: http://bit.ly/VikasNehraTwitterHandle
Vikas Nehra’s FB Account: https://www.facebook.com/er.vikasnehra/
Vikas Nehra’s Instagram Handle: https://www.instagram.com/er.vikasnehra/
Registration Form: http://bit.ly/NehraClassesRegForm
Twitter Handle: http://bit.ly/NehraClassesTwiiterHandle
Facebook Page: www.facebook.com/nehraclasses
Instagram: https://www.instagram.com/nehraclasses/
Telegram Channel: https://t.me/NehraClasses
WhatsApp Us: https://bit.ly/2Kpqp5z
Email Us: [email protected]
===
©COPYRIGHT. ALL RIGHTS RESERVED.

#NehraClasses #LinuxTraining #Trending

Comments are closed.