Connecting to a Windows machine with Ansible I'm trying to simply connect to a machine and run the win_ping module.

There are several tutorials online that outline a few key steps:


Create a directory ./windows
Create a file hosts in ./windows
Create a directory ./windows/group_vars
Create a file windows.yml in ./windows/group_vars
Insert several variables with your Windows credentials into windows.yml


The problem is that none of these actually specify where to put these relative to the '.'.  I've tried placing this structure in /etc/ansible/ and unfortunately it's looking like Ansible isn't picking this up at all.  I've also tried moving the structure around but no luck.

How do I get Ansible to reference the directory I've created?  I believe ansible.cfg would make sense but I can only see how to point it to a default inventory file. Interestingly enough - even adding a group called 'windows' in the base hosts file and calling ansible with the group there - it says no hosts found. I have also uncommented the inventory location in ansible.cfg to point to /etc/ansible/hosts and it still says no hosts found when calling ansible windows -m ping (or win_ping for that matter).
There are two places where Ansible looks for group_vars subdirectory:


the playbook directory - the one containing a playbook you run
the inventory directory - the one specified with -i option at run time, or a default one (usually /etc/ansible, or /usr/local/etc/ansible)


In most typical scenario you might place group_vars along with the playbook.yml.

The example you posted uses the second method, so to reference the files you need to add -i to the command:

ansible windows -m ping -i ./windows