How To Install Ansible On RHEL 8

How To Install Ansible On RHEL 8

update your rhel system packages with update command

yum update -y

Install Python On Rhel

Basic prerequisite for ansible is python so install python on your rhel 8 /redhat 8 server

yum install python3 -y
sudo alternatives --set python /usr/bin/python3

Create User For Ansible

in the following steps i am going to install ansible with pip3 which requires a different user rather than root.

adduser devops

here devops is the new user which i am going to use for ansible.

switch to user

su - devops

right now i am in devops user. so we can install ansible.

Install ansible with Pip3

execute below command to install ansible.

pip3 install ansible --user

verify ansible with below command

[devops@ip-172-31-88-160 ~]$ ansible --version
ansible 2.9.0
  config file = None
  configured module search path = ['/home/devops/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/devops/.local/lib/python3.6/site-packages/ansible
  executable location = /home/devops/.local/bin/ansible
  python version = 3.6.8 (default, Oct 11 2019, 15:04:54) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]

Note: you can not use ansible with root or any other users. you can use ansible only with the user(here devops in my case) which used for installation. since pip3 install ansible packages in user home directory.

2nd Method:

Install ansible with virtual environment

execute below commands to install python3

yum update -y
yum install python3 -y
sudo alternatives --set python /usr/bin/python3

Install git

install git to download ansible executable files

yum install git -y
git clone https://github.com/ansible/ansible.git

Install Ansible on Rhel 8/Redhat 8

execute below commands to install ansible on rhel 8 or redhat 8

cd ansible
yum install python3-virtualenv
virtualenv venv
source venv/bin/activate
pip install .

Verify Ansible Path

using which command we can verify ansible path

which ansible

Leave a Reply

Your email address will not be published. Required fields are marked *