Search code examples
ansibleansible-inventory

ansible execute a single module on a single host


I would like to do something like this :

ansible -i MYHOST, windows -m win_ping

I have MYHOST that is in the inventory windows but I get this answer:

[WARNING]: No hosts matched, nothing to do

How can I select a specific host?


Solution

  • You've got your parameters and their values in wrong order. It should be:

    ansible MYHOST -i windows -m win_ping
    

    The value of -i argument points to the inventory file, host pattern should be given directly.

    You also don't need a comma, it was an old hack for defining the target without a need for inventory file.