What you'll learn
- Introduction
- Root Cause
- Common Module Mapping: Linux vs Windows
- How to Identify This Error
- Playbook
- error code
- error execution
- fix code
- fix execution
- Conclusion
Introduction
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.
Root Cause
The error occurs when you use a **Linux/Unix module** (`ansible.builtin.get_url`) on a **Windows target**. Ansible tries to execute Python code on the Windows host, but Windows runs PowerShell — not Python. The error message shows PowerShell trying to parse Python syntax and failing.
**The fix:** Use the Windows-specific module `ansible.windows.win_get_url` instead of `ansible.builtin.get_url`.
Common Module Mapping: Linux vs Windows
| Linux Module | Windows Module | Purpose |
|---|---|---|
| `ansible.builtin.get_url` | `ansible.windows.win_get_url` | Download files |
| `ansible.builtin.copy` | `ansible.windows.win_copy` | Copy files to remote |
| `ansible.builtin.file` | `ansible.windows.win_file` | Manage files/directories |
| `ansible.builtin.template` | `ansible.windows.win_template` | Deploy templates |
| `ansible.builtin.service` | `ansible.windows.win_service` | Manage services |
| `ansible.builtin.user` | `ansible.windows.win_user` | Manage users |
| `ansible.builtin.package` | `chocolatey.chocolatey.win_chocolatey` | Install packages |
| `ansible.builtin.command` | `ansible.windows.win_command` | Run commands |
| `ansible.builtin.shell` | `ansible.windows.win_shell` | Run shell commands |
How to Identify This Error
Look for these signs in the error output:
1. **"No python interpreters found"** — Ansible is looking for Python on a Windows host
2. **PowerShell parse errors** — `"An expression was expected after"`, `ParseException`
3. **"MODULE FAILURE"** with `rc: 1`
4. Python syntax in `module_stderr` — `def`, `import`, `sys.version_info`
Playbook
How to troubleshoot the Module Failure on Windows-target.
error code
```yaml
---
- name: win_get_url module Playbook
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
```bash
ansible-pilot $ ansible-playbook -i virtualmachines/win/inventory troubleshooting/get_url_error.yml
PLAY [win_get_url module Playbook] ********************************************************************
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_