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:
https://www.ansible.com/blog/connecting-to-a-windows-host
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:

[win]
192.168.1.105

[win:vars]
ansible_connection=winrm
ansible_winrm_server_cert_validation=ignore

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

[inventory]
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

LEAVE A COMMENT