0

I created an inventory file has .yml extension like below:

---
  all:
    server1
    hosts:
      server2
    children:
      hana:
        prod:
          client1:
            hosts:
              server3
          client2:
            hosts:
              server4
        test:
          client1:
            hosts:
              server5
          client1:
            hosts:
              server6
...

Then I ran ping ad-hoc for all hosts with below command:

ansible -m ping -i /etc/ansible/inventories/linuxall.yml all

And I saw these warnings and ping didn't work:

 [WARNING]: Unable to parse /etc/ansible/inventories/linuxall.yml 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'

Why ansible cannot parse my inventory? Should I do anything for this?

3 Answers 3

1

In the example on the following link every line, including the server names, ends with a colon character:

https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html

1
  • thanks. I saw this tutorial. I found the the reason of the problem. I'll add an solution asap. It's not about the file, it's about config file. Oct 14, 2019 at 13:52
1

I found the problem and solution:

There is a section named [inventory] in the ansible.cfg file. Remove # character at the start of line "enable inventory plugins...". Then .yml and .yaml inventory files will been activated.

Also, ":" character is necessary after every line else hostnames too.

0

For me, the fix was: I needed to specify the location of playbook.yml with the -K switch

ansible-playbook -K /root/myplatform/playbook.yml
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .