Ansible for Windows: strange behavior

1,988 views
Skip to first unread message

Michele Viviani

unread,
Mar 17, 2017, 6:17:19 AM3/17/17
to Ansible Project
Hi,
I do have some problems using Ansible with Windows.
For many of my servers it works, but for some I'm receiving "HTTPConnectionPool(host='10.10.193.180', port=5985): Read timed out" even if the WinRM configuration is correct. (it's the same as several others)
More over, if I run a Enter-PSSession myhost.domain.com from another Windows server, it works and after that command also ansible win_ping is responding.

Below my test case
*************
[ro...@ansible.domain.com ~]# ansible windows -m win_ping
10.10.193.180 | UNREACHABLE! => {
    "changed": false,
    "msg": "ntlm: HTTPConnectionPool(host='10.229.193.180', port=5985): Read timed out. (read timeout=30)",
    "unreachable": true
}
*************
Executing successfully  Enter-PSSession myhost.domain.com from a Windows server
*************
[ro...@ansible.domain.com ~]# ansible windows -m win_ping
10.10.193.180 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}
*************
here my settings

[ro...@ansible.domain.com ~]# ansible --version
ansible 2.2.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
[ro...@ansible.domain.com ~]# python -V
Python 2.7.5

Any ideas/help?

Thanks a lot!!
Mike

J Hawkesworth

unread,
Mar 17, 2017, 8:45:21 AM3/17/17
to Ansible Project
Anything in the event log on the affected machines?

Do the affected machines run IIS?  I recall a problem where the remoting didn't work fully when some domain account mapping configuration was in place (unfortunately I don't now remember the name of the domain user mapping mechanism, so can't search for it).

Is there anything else different about the affected machines?  Load? Network proximity?

Hope this helps,

Jon

Matt Davis

unread,
Mar 17, 2017, 6:49:06 PM3/17/17
to Ansible Project
The only time I've ever seen that behavior is on the first request to a brand-new Windows AWS instance. For some reason, the shell creation can take up to 30s, much longer than our default operation timeout of ~5s.

You can try increasing the operation and read timeouts by adjusting the ansible_winrm_operation_timeout_sec and ansible_winrm_read_timeout_sec inventory vars (the read timeout must be > than operation timeout). They're set to relatively low values to minimize the "dead host" detection interval, and this doesn't typically cause problems in normal operation.

-Matt

Michele Viviani

unread,
Mar 20, 2017, 9:45:17 AM3/20/17
to Ansible Project
Hi Matt,
thanks for the suggestion. I've added

ansible_winrm_operation_timeout_sec: 100 and

ansible_winrm_read_timeout_sec: 120

to my settings and now it works!!

Mike
Reply all
Reply to author
Forward
0 new messages