Ansible troubleshooting — Module Failure on Windows-target
How to reproduce, troubleshoot, and fix the Module Failure Ansible fatal error on Windows-target. Demo code included for download file example.
4 min readFeb 8, 2022
--
Today we’re going to talk about Ansible troubleshooting, specifically about the Module Failure on Windows-target.
I’m Luca Berton and welcome to today’s episode of Ansible Pilot.
demo
How to troubleshoot the Module Failure on Windows-target.
error code
---
- name: win_get_url module demo
hosts: all
become: false
vars:
myurl: "https://releases.ansible.com/ansible/ansible-2.9.25.tar.gz"
mydest: 'C:\Users\vagrant\Desktop\ansible-2.9.25.tar.gz'
tasks:
- name: download file
ansible.builtin.get_url:
url: "{{ myurl }}"
dest: "{{ mydest }}"
error execution
ansible-pilot $ ansible-playbook -i virtualmachines/win/inventory troubleshooting/get_url_error.ymlPLAY [win_get_url module demo] ********************************************************************TASK [Gathering Facts] ****************************************************************************
ok: [WindowsServer]TASK [download file] ******************************************************************************
[WARNING]: No python interpreters found for host WindowsServer (tried ['python3.10', 'python3.9',
'python3.8', 'python3.7', 'python3.6', 'python3.5', '/usr/bin/python3', '/usr/libexec/platform-
python', 'python2.7', 'python2.6', '/usr/bin/python', 'python'])
fatal: [WindowsServer]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "module_stderr": "Exception calling \"Create\" with \"1\" argument(s): \"At line:4 char:21\r\n+ def _ansiballz_main():\r\n+ ~\r\nAn expression was expected after '('.\r\nAt line:8 char:19\r\n+ os.getcwd()\r\n+ ~\r\nAn expression was expected after '('.\r\nAt line:20 char:27\r\n+ except (AttributeError…