winrm Unable to connect to windows10 desktop

2,023 views
Skip to first unread message

Deep18

unread,
Aug 22, 2016, 2:17:34 PM8/22/16
to Ansible Project, dnv...@dolby.com

Hi,

I am trying to use ansible to controla windows 10 desktop VM in my lab and cannot seem to get past the connection error.Appreciate your help here.


Here is my setup:

MacBook is the control host and trying to connect to a windows10 desktop VM. I went through and followed all instructions in the ansible doc to enable remotePowershell on windows VM, turned OFF firewall on the windows VM.The windows VM is not part of any domain.


My inventory file:

[windows]

10.203.189.4

[windows:vars]                                      #group variables and values as a string

      ansible_connection=winrm 

      ansible_user= voiceqa

      ansible_password = abcdef

      ansible_port=5986

      ansible_winrm_server_cert_validation= ignore


I get the following error:


$ ansible windows --inventory-file=./hosts  -m win_ping -vvvvv

No config file found; using defaults

Loaded callback minimal of type stdout, v2.0

<10.203.189.4> ESTABLISH WINRM CONNECTION FOR USER: voiceqa on PORT 5986 TO 10.203.189.4

<10.203.189.4> WINRM CONNECT: transport=ssl endpoint=https://10.203.189.4:5986/wsman

<10.203.189.4> WINRM CONNECTION ERROR: HTTPSConnectionPool(host='10.203.189.4', port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x10e61c8d0>: Failed to establish a new connection: [Errno 61] Connection refused',))

Traceback (most recent call last):

  File "/Users/dnveer/venv/vqp/lib/python2.7/site-packages/ansible/plugins/connection/winrm.py", line 134, in _winrm_connect

    protocol.send_message('')

  File "/Users/dnveer/venv/vqp/lib/python2.7/site-packages/winrm/protocol.py", line 207, in send_message

    return self.transport.send_message(message)

  File "/Users/dnveer/venv/vqp/lib/python2.7/site-packages/winrm/transport.py", line 173, in send_message

    response = self.session.send(prepared_request, timeout=self.read_timeout_sec)

  File "/Users/dnveer/venv/vqp/lib/python2.7/site-packages/requests/sessions.py", line 585, in send

    r = adapter.send(request, **kwargs)

  File "/Users/dnveer/venv/vqp/lib/python2.7/site-packages/requests/adapters.py", line 467, in send

    raise ConnectionError(e, request=request)

ConnectionError: HTTPSConnectionPool(host='10.203.189.4', port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x10e61c8d0>: Failed to establish a new connection: [Errno 61] Connection refused',))


10.203.189.4 | FAILED! => {

    "failed": true, 

    "msg": "ssl: HTTPSConnectionPool(host='10.203.189.4', port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x10e61c8d0>: Failed to establish a new connection: [Errno 61] Connection refused',))"

}

J Hawkesworth

unread,
Aug 23, 2016, 2:57:11 AM8/23/16
to Ansible Project, dnv...@dolby.com
So ... you are getting connection refused.  So winrm is connecting but isn't happy with something.
Have a look in the event logs on the windows box to see if there is anything appearing when you attempt to connect.

Actually I think its possible that the problem is your inventory file.  I suggest you remove the spaces in

      ansible_user= voiceqa

      ansible_password = abcdef


So they look like this:


      ansible_user=voiceqa

      ansible_password=abcdef


Give that a try and let us know how you get on.

Jon

Deep18

unread,
Aug 25, 2016, 1:06:52 PM8/25/16
to Ansible Project, dnv...@dolby.com
 I had to delete the 127.0.0.1 port from listening on the http to get the win_ping working.

Cloudn Loud

unread,
Aug 15, 2017, 9:58:11 AM8/15/17
to Ansible Project, dnv...@dolby.com
I am also getting the same issue from ansible linux server to win10 machine.

where you  deleted the 127.0.0.1 port in windows server host file or linux server host file ?

Thanks,
Sangeetha

Chris

unread,
Aug 15, 2017, 11:26:30 AM8/15/17
to Ansible Project, dnv...@dolby.com
He's talking about on the Windows host.  I didn't have to do that with Windows Server 2008, but it could be he had something from a previous setup using the default port.  As a best practice you should never use HTTP. Add this line to your inventory file:

ansible_ssh_port=5986


Then verify the port is not is use by anything on the Windows host.  I'm guessing you already enabled WinRM, you can also check the listener: winrm enumerate winrm/config/listener
Reply all
Reply to author
Forward
0 new messages