Ansible is a very powerful open-source IT automation tool. It is known as a configuration management tool. Ansible is written in Python language, so it requires Python to be available on the machine. We can use Ansible to automate software installation, software configuration, configuration management, etc.
To get a quick high-level understanding of Ansible, please review the article below.
To use Ansible for your automation purpose you would need a machine where Ansible needs to be installed and this is called ansible-host or ansible-controller. And you would need other machines (remote or target machines) where Ansible will perform the tasks.
There are multiple ways to install Ansible in RHEL. Below are the two most used methods.
- Ansible installation using RHEL package manager.
- Ansible installation using the pip module of Python.
In this article, we will see how to install Ansible using the RHEL package manager in a step-by-step manner.
- Since we will install Ansible on RHEL (Red Hat Enterprise Linux), you must have an RHEL machine connected to the Red Hat subscription manager.
- On the RHEL machine, you would need a user which has sudo privileges.
Steps/Commands to install Ansible
As of April 2023, the latest version of Ansible is 2.13.x (ansible core). We will be installing the same.
We will be using dnf to install Ansible. (dnf is the package management utility for RHEL, Fedora, and Centos).
Step 1: Update OS
# Run the below command to update the RHEL OS.
sudo dnf update -y
Step 2: Install Python
# Check whether Python is installed or not. RHEL 8 comes with python3. So, we don’t need to install Python.
# If Python is not installed, then run the below command to install it.
sudo dnf install python3
Step 3: Enable repos for Ansible
# List the available repos that include ansible-core packages
sudo dnf list ansible-core
sudo dnf info ansible-core
In the output of the above, we will see the repo name. We need to enable that repo.
# Enable the repo that includes the ansible-core package.
sudo subscription-manager repos --enable <repo name>
Step 4: Install Ansible
# Run the below commands to install Ansible
sudo dnf install ansible -y
# Finally, we can check the version of Ansible.
Apart from the above method of Ansible installation, we can install Ansible by following the official documentation of Ansible.
If you are interested in learning DevOps, please have a look at the below articles, which will help you greatly.
- Introduction to Ansible | High Level Understanding of Ansible
- Basics of automation using Ansible | Automate any task
- Automation of Java installation – using Ansible
- Automation of Tomcat installation – using Ansible
- 10 frequently used ansible modules with example
- Jenkins Pipeline as code – High level information
- Jenkins pipeline script to build Java application and push artifacts into repository
- Jenkins pipeline script to build & deploy application on web server
- What is End-to-End Monitoring of any web application, and Why do we need it?
- What is “Monitoring” in DevOps? Why do we need to Monitor App/DB servers, Transactions etc.?
- DevOps Engineer or Software Developer Engineer which is better for you?- Let’s discuss
- How To Be A Good DevOps Engineer?
- How to do git push, git pull, git add, git commit etc. with Bitbucket