0
votes

I am trying to set up my ansible host to connect to windows. However ping is failing with the following error:

sudo ansible win -m win_ping hostname | UNREACHABLE! => { "changed": false, "msg": "basic: HTTPConnectionPool(host='hostname', port=5986): Read timed out. (read timeout=30)", "unreachable": true }

pywinrm is installed on my linux box and WinRM is installed on the windows box.

Hosts file:

[win]
systemname
[win:vars]
ansible_user=username
ansible_password=passord
ansible_connection=winrm
ansible_winrm_scheme=http
ansible_winrm_server_cert_validation=ignore
ansible_winrm_transport=basic

Appreciate any advice. Thanks.

2
Can you ping it normally? Does the firewall allow winrm?dan1st
yes ping is successful from linux to windows.James Rubin
and the firewall rules has "Allow WinRM HTTPS" for port 5986James Rubin
Is winrm listening on 0.0.0.0? (You can test it with netstat -an)dan1st
TCP 0.0.0.0:5985 0.0.0.0:0 LISTENING TCP 0.0.0.0:5986 0.0.0.0:0 LISTENINGJames Rubin

2 Answers

0
votes

Disabling the Windows Firewall (Domain, private and public networks) in the Windows box, fixed the issue for me.

0
votes

Can you double check the WinRM Listener settings:

winrm enumerate winrm/config/Listener

If the output is what you expect, can you test a command on the local server as shown here:

winrs -r:http://server:5985/wsman -u:Username -p:Password ipconfig

Ansible has a good reference on this topic as well.