pythonpipansibleyum

How to install ansible in Red Hat Enterprise Linux 8.2


I am trying to install ansible in Azure VM

It was told " Ansible is not part of your RedHat DVD. It is a part of the python package. You need to install Ansible using the pip3 command "

After successfully installation with command pip3 install ansible

I don't see ansible command is not getting resolved. Could some guide me how to install ansible in right way?

[root@automation azureuser]# ansible
bash: ansible: command not found

Some diagnostic commands:

[root@automation site-packages]# echo $PATH 
/sbin:/bin:/usr/sbin:/usr/bin

[root@automation site-packages]# whereis ansible
ansible: /usr/local/bin/ansible

[root@automation site-packages]# which ansible
/usr/bin/which: no ansible in (/sbin:/bin:/usr/sbin:/usr/bin)

Solution

  • Your PATH variable is /sbin:/bin:/usr/sbin:/usr/bin and that means that bash will search for ansible in these directories, however ansible placed in /usr/local/bin

    You have to add /usr/local/bin to $PATH

    How tos: 1, 2, 3

    Also if you switch to non-root user /usr/local/bin should be present in $PATH by default (if I remember it correctly)

    PS if you switched to root by using sudo su, use sudo su - instead. When you adding - some extra user specific variables will be imported (including extended $PATH)