Linux – Ansible “provided hosts list is empty” error

ansiblelinuxyaml

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?

Best Answer

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

Related Question