I'm running into some on and off issues when using windows hosts in my Ansible playbooks. I'm running Ansible 2.3 with pywinrm 0.2.2 installed. I'm using basic authentication with the local Administrator user.

Sometimes I receive this issue when I run a task:

[WARNING]: FATAL ERROR DURING FILE TRANSFER: Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/ansible/plugins/connection/winrm.py", line 267, in _winrm_exec self._winrm_send_input(self.protocol, self.shell_id, command_id, data, eof=is_last) File "/usr/local/lib/python2.7/dist-packages/ansible/plugins/connection/winrm.py", line 248, in _winrm_send_input protocol.send_message(xmltodict.unparse(rq)) File "/usr/local/lib/python2.7/dist-packages/winrm/protocol.py", line 207, in send_message return self.transport.send_message(message) File "/usr/local/lib/python2.7/dist-packages/winrm/transport.py", line 191, in send_message raise WinRMTransportError('http', error_message) WinRMTransportError: (u'http', u'Bad HTTP response returned from server. Code 500')

Other times, when I try to run a win_shell/win_command/raw module and with_items on a group of windows hosts it seems to fail on temporary files created by Ansible.

The task I'm trying to run is:

- name: Check services up win_command: 'sc queryex {{ item }} | Findstr RUNNING' with_items: '{{ component_services }}' register: command_result ignore_errors: yes

And the error I may get is:

changed: [172.16.104.169] => (item=Dnscache) failed: [172.16.104.176] (item=Dnscache) => {"failed": true, "item": "Dnscache", "module_stderr": "Exception calling \"Run\" with \"1\" argument(s): \"Exception calling \"Invoke\" with \r

\"0\" argument(s): \"The running command stopped because the preference variable \r

\"ErrorActionPreference\" or common parameter is set to Stop: (0) : cannot open \r

C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\RESB3FF.tmp for writing\r

(1) : using System;\r

\"\"\r

At line:45 char:1\r

+ $output = $entrypoint.Run($payload)\r

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r

+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordE \r

xception\r

+ FullyQualifiedErrorId : ScriptMethodRuntimeException\r

", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 1} changed: [172.16.104.141] => (item=Dnscache) changed: [172.16.104.168] => (item=Dnscache) changed: [172.16.104.145] => (item=Dnscache)

Both issues are absolutely random and may even not appear at all over a sequence of different runs.

Any assistance?