| Forum

Ansible host file not found in RHEL 8.3 after installing ansible

I have installed Ansible in RHEL 8.3. I am not able to find the ansible host file in the default /ansible/hosts location.

Also, the anisble path was not set automatically, I had to set it manually in profile file.

If the ansible path is not set, you can set it by editing the .bash_profile file. Add the current path of ansible to the path variable as shown below. If you are not aware of the current path, use the find command (find / -name ansible) to find it. If you installed using root user it might be /root/.local/bin, or else if you installed using another user, it will be in the $HOME/.local/bin

vi ~/.bash_profile

if [ -f ~/.bashrc ]; then. ~/.bashrcfi
export PATH

At times the /etc/ansible/hosts file may not be present after the installation. You can create it manually.

mkdir /etc/ansible
cd /etc/ansible
touch /etc/ansible/hosts

Also you need to create the ansible.cfg file under /etc/ansible folder.

find / -name ansible.cfg

From the results, copy the ansible.cfg file to the /etc/ansible folder.

for eg:

find / -name ansible.cfg
/root/.local/lib/python3.6/site-packages/ansible_collections/infinidat/infinibox                                                                                                             /playbooks/ansible.cfg

cp /root/.local/lib/python3.6/site-packages/ansible_collections/infinidat/infinibox/playbooks/ansible.cfg /etc/ansible/

Now when you check ansible --version, you will notice the anibsle config file pointing towards /etc/ansible/ansible.cfg