On my (winrm) target host, I am able to run the following:
PS C:\Users\agenerette> c:/Python27/python.exe c:/xx/run/yy/tests/confluence_api_test.py
When I try to incorporate that into a playbook, however, I get a great block of mostly encoded error output that I’m not able to make sense of. I’ve attached a couple of screen-shots to give a more complete picture of what I’m seeing, but here’s an excerpt:
PLAY [873320-wrk04-ia] *********************************************************
TASK [Do a test run of Sharefiles and Confluence API scripts…] ***************
Traceback (most recent call last):
File “/usr/lib/python2.6/site-packages/ansible/plugins/connection/winrm.py”, line 274, in exec_command
result = self._winrm_exec(cmd_parts[0], cmd_parts[1:], from_exec=True)
File “/usr/lib/python2.6/site-packages/ansible/plugins/connection/winrm.py”, line 219, in _winrm_exec
response = Response(self.protocol.get_command_output(self.shell_id, command_id))
File “/home/agenerette/.local/lib/python2.6/site-packages/winrm/protocol.py”, line 398, in get_command_output
self._raw_get_command_output(shell_id, command_id)
File “/home/agenerette/.local/lib/python2.6/site-packages/winrm/protocol.py”, line 417, in _raw_get_command_output
res = self.send_message(xmltodict.unparse(req))
File “/home/agenerette/.local/lib/python2.6/site-packages/winrm/protocol.py”, line 244, in send_message
fault = root.find(‘soapenv:Body/soapenv:Fault’, xmlns)
TypeError: find() takes exactly 2 arguments (3 given)
failed: [873320-wrk04-ia] (item=c:/t3/run/ae/tests/sharefile_api_test.py) => {“item”: “c:/t3/run/ae/tests/sharefile_api_test.py”, “msg”: "failed to exec cmd PowerShell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -EncodedCommand
And here’s a copy of the playbook:
- hosts: “{{ targets }}”
user: “{{ admin }}”
gather_facts: yes
vars:
python_exec: c:/Python27/python.exe
working_dir: c:/xx/run/yy
sharefile_script: c:/xx/run/yy/tests/sharefile_api_test.py
confl_script: c:/xx/run/yy/tests/confluence_api_test.py
tasks:
- name: Do a test run of Sharefiles and Confluence API scripts…
win_shell: “‘{{ python_exec }} {{ item }}’”
win_shell: “Get-Item Env:ldap_user”
with_items:
“{{ sharefile_script }}”
“{{ confl_script }}”
environment:
LDAP_USER: “{{ my_ldap_user }}”
LDAP_REG_CODE: “null”
LDAP_PASS: “{{ my_ldap_pass }}”
GDOC_PASS: “{{ my_gdoc_pass }}”
SHARE_USER: “{{ my_sharefiles_user }}”
SHARE_PASS: “{{ my_sharefiles_pass }}”
WIKI_USERNAME: “{{ my_ldap_user }}”
WIKI_PASSWORD: “{{ my_ldap_pass }}”
ignore_errors: yes
register: result
- debug: var=result