Hi
I hit upon an issue using ansible to run PowerShell commands against windows nodes. I followed the instructions and got the basics working. On my linux controller node I had Python 2.6.6 and when running the simple setup module I got this error:
python ansible windows -m setup
Traceback (most recent call last):
File “/root/projects/ansible/lib/ansible/runner/connection_plugins/winrm.py”, line 150, in exec_command
result = self._winrm_exec(cmd_parts[0], cmd_parts[1:], from_exec=True)
File “/root/projects/ansible/lib/ansible/runner/connection_plugins/winrm.py”, line 121, in _winrm_exec
vvvv(‘WINRM RESULT %r’ % response, host=self.host)
File “/usr/lib/python2.6/site-packages/winrm/init.py”, line 12, in repr
self.status_code, self.std_out[:20], self.std_err[:20])
ValueError: zero length field name in format
It is because the code in repr() of /winrm/init.py has omitted positional argument specifier in the format string which will work only in Python 2.7 & above but not in Python 2.6, which is suggested in Ansible docs.
I fixed the above by changing the line to:
return ‘<Response code {0}, out “{1}”, err “{2}”>’.format(…)
I thought I would share this so that it might help anyone who gets stuck with this issue.
-Venkat