'Issue with connection established from ansible to windows

WinRM service is already running on this windows machine, but when I run my playbook against a Windows node I'm getting below error.

error: fatal: [xx:xx:xx:xxx]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh_exchange_identification: Connection closed by remote host", "unreachable": true}

Could you please let me know if anything is missing or incorrect

Regards, Priya P



Solution 1:[1]

As Zeitounator said:

Add winrm connection details. Ie. if you have an ini inventory with a windows group: (put the credentials in a vault)

[windows:vars]
ansible_user=<from vault>
ansible_password=<from vault>
ansible_connection=winrm
ansible_winrm_server_cert_validation=ignore
ansible_port=5986
#ansible_port=5985
ansible_winrm_transport=ntlm
ansible_winrm_scheme=https
#ansible_winrm_scheme=http

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jeroenflvr