Search code examples
linuxansiblevirtual-machineansible-inventory

ansible playbook with host group running - No host matched


When I perform

ansible -i /home/linux/ansible/my-prereqs/hosts  -m ping 'test'


172.16.57.101 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}

my host inventory file is located in /home/linux/ansible/my-prereqs/hosts

my inventory file is like below

[ansible-vm]
172.16.57.102

**[test]**
172.16.57.101

Now I want to run a play book but I am not able to run them by inventory groups

ansible-playbook  -i /home/linux/ansible/my-prereqs/hosts  -l test my-prereqs.yaml 

but I get the following 


PLAY ***************************************************************************
skipping: no hosts matched

PLAY RECAP *********************************************************************

What am I missing here for my arguments ?


Solution

  • Answer from the comments:

    What is the hosts directive in your playbook?

    ...

    It was different from the inventory file group name