Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible :Unable to parse /etc/ansible/hosts as an inventory source

I am new to ansible, got the below issue. I was able to ssh into my client machine .but unable to run playbook.

Getting the error below:

[WARNING]: Unable to parse /etc/ansible/hosts as an inventory source

 [WARNING]: No inventory was parsed, only implicit localhost is available

 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit
localhost does not match 'all'

 [WARNING]: Could not match supplied host pattern, ignoring: a

here a is my group name. my hosts given below :

---------


[a]
172.31.26.93



[all:vars]

ansible_user=vagrant
ansible_ssh_pass=vagrant


 ansible_ssh_host=172.31.26.93
 ansible_ssh_port=22
 ansible_ssh_user='ansibleuser'
 ansible_ssh_private_key_file=/home/ansibleuser/.ssh

------- my playbook file given below ----

- hosts: a
  tasks:
  - name: create a directory
    file: path=/home/ansiblesuser/www state=directory

This is the first time I am getting this issue.

like image 563
MANI KANTA Avatar asked Nov 08 '18 10:11

MANI KANTA


People also ask

How do I see Ansible hosts?

You can use the option --list-hosts. It will show all the host IPs from your inventory file.


1 Answers

Before running the playbook just run the following command

ansible all --list-hosts

If the above error persists then go to /etc/ansible/ansible.cfg and edit the inventory path which points to your specific host file.

like image 50
sumitsinghdeode Avatar answered Sep 20 '22 12:09

sumitsinghdeode