Ansible on Linux VM, connecting to Windows Host: "Could not match host pattern"

  ansible, linux, windows, winrm

I have Ansible running on Linux Mint on an Oracle VM. I am following this tutorial:
to test communication with my host OS, Windows 10. Bridged networking is set up.

I have done the following steps:

  • install Ansible on the Linux VM
  • install Python 3.9 on Windows
  • set up WinRM on Windows
  • configure hosts and ansible.cfg files for Ansible on Linux VM

This is what the /etc/ansible/hosts file looks like:



This is what the /etc/ansible/ansible.cfg file looks like:

inventory = /etc/ansible/hosts

Running the command: ansible [win] -i hosts -m win_ping yields an error:

[WARNING]: Could not match supplied host pattern, ignoring: [win]
[WARNING]: No hosts matched, nothing to do

What is the cause of this, and how to fix it?

Source: Windows Questions