unable to setup windows host for ansible

113 views
Skip to first unread message

Nk Chitturi

unread,
Oct 25, 2018, 4:35:02 PM10/25/18
to Ansible Project
I am trying to run ping command on my windows host from  linux controller

i created inventory.txt file
[win]
servername
[win:vars]
ansible_user=myusername
ansible_password=password
ansible_connection=winrm
ansible_winrm_transport=basic
ansible_winrm_server_cert_validation=ignore
ansible_port=5986

the error Iam getting is  

servername | UNREACHABLE! => {
    "changed": false,
    "msg": "basic: HTTPSConnectionPool(host='servernname', port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f8ad0f13f90>: Failed to establish a new connection: [Errno 111] Connection refused',))",
    "unreachable": true
}

ameya agashe

unread,
Oct 25, 2018, 5:34:17 PM10/25/18
to ansible...@googlegroups.com
Simple and easy fix.

Run on the remote computer the following command.
netsh advfirewall firewall add rule name="Allow WinRM (Http)" dir=in localport=5985 protocol=tcp action=allow enable=yes
netsh advfirewall firewall add rule name="Allow WinRM (Https)" dir=in localport=5986 protocol=tcp action=allow enable=yes

This should fix your problem.

Kind Regards
Ameya Agashe

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/e7b4d353-00d6-41eb-8914-c2fa40bcfbaa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nk Chitturi

unread,
Oct 25, 2018, 6:13:56 PM10/25/18
to ansible...@googlegroups.com
thanks for that, but still I am getting same error.
my host machine is w windows 2016 and linux controller is centos and they both were on same corporate domain.
any suggestions.. 


For more options, visit https://groups.google.com/d/optout.


--
 
 

ameya agashe

unread,
Oct 25, 2018, 6:28:11 PM10/25/18
to ansible...@googlegroups.com
Not possible, it should work, I had the same issue. What error message are you getting now? ARe you able to ping the server? Can you post the screenshot of Windows firewall for ports 5985 and 5986. Also, important that user " myusername" does exist on that remote Windows Server.

I have done this setup for Windows Server 2016 and SQL Server 2014 SP2 and it works like a charm!

Kind Regards
Ameya Agashe



Nk Chitturi

unread,
Oct 25, 2018, 6:42:08 PM10/25/18
to ansible...@googlegroups.com
image.png


image.png

image.png
here are the images.


For more options, visit https://groups.google.com/d/optout.


--
 
 

ameya agashe

unread,
Oct 25, 2018, 6:56:15 PM10/25/18
to ansible...@googlegroups.com
Ok, I see duplicate firewall rules to delete the one which you just added. Something is odd, are you able to ping them without ansible? Are you able to login to the remote server with username and password defined in inventory?

If that also fails, let us see what others may have to comment as this setup works for me without any issues

Kind Regards
Ameya Agashe

Nk Chitturi

unread,
Oct 25, 2018, 7:08:16 PM10/25/18
to ansible...@googlegroups.com
Yes Ameya, I am able to login to the server with same credentials.
I deleted duplicate entries for firewall rules. 


For more options, visit https://groups.google.com/d/optout.


--
 
 

ameya agashe

unread,
Oct 25, 2018, 7:49:09 PM10/25/18
to ansible...@googlegroups.com
Ok, if it is still not working suggest you perform the following activities
1. telnet <hostname> 5985
    telnet <hostname> 5986
2. Restart windows
3 Run ansible with -vvv option.

Keep us posted, need to have this resolved as you cannot automate anything in Windows until WInRM is working.

KInd Regards
Ameya Agashe

Nk Chitturi

unread,
Oct 25, 2018, 8:13:22 PM10/25/18
to ansible...@googlegroups.com
Ameya, where should i do telnet ..



For more options, visit https://groups.google.com/d/optout.


--
 
 

ameya agashe

unread,
Oct 25, 2018, 8:24:21 PM10/25/18
to ansible...@googlegroups.com
Windows Server you want to test connectivity on that port from your host/Ansible controller.

Ameya

Nk Chitturi

unread,
Oct 25, 2018, 8:37:25 PM10/25/18
to ansible...@googlegroups.com
This is on linux server, tried to telnet to windows host

image.png


For more options, visit https://groups.google.com/d/optout.


--
 
 

ameya agashe

unread,
Oct 25, 2018, 8:40:43 PM10/25/18
to ansible...@googlegroups.com
Appears that 5986 is denying the connection, investigate why?

Is WInRM service running on Remote Windows Host?

Ameya

nadim mansour

unread,
Nov 1, 2018, 9:08:00 AM11/1/18
to ansible...@googlegroups.com
did you manage to solve the problem ?
I run both rules but still not able to run ansible to windows server.

Mike Fennemore

unread,
Nov 1, 2018, 2:54:38 PM11/1/18
to Ansible Project
ansible_winrm_transport:ntlm try that instead of ansible_winrm_transport:basic

Nk Chitturi

unread,
Nov 1, 2018, 3:58:35 PM11/1/18
to ansible...@googlegroups.com
I haven’t tried yet, I am working with my netops and infra team about it.

Sent from my iPhone

> On Nov 1, 2018, at 11:54 AM, Mike Fennemore <mike.fe...@sentia.com> wrote:
>
> ansible_winrm_transport:ntlm try that instead of ansible_winrm_transport:basic
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/555c2482-90e7-4c4d-b249-1e4fe387f245%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages