The Error

fatal: [webserver]: FAILED! => {
    "changed": false,
    "module_stderr": "",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

Step 1: Get More Details with -vvv

ansible-playbook playbook.yml -vvvv

The verbose output usually reveals the actual Python traceback.

Step 2: Common Causes & Fixes

Missing Python Library on Remote Host

ModuleNotFoundError: No module named 'selinux'
- name: Install required Python library
  ansible.builtin.pip:
    name: selinux
  become: true

Wrong Module Arguments

# WRONG — 'src' is not a valid parameter for apt
- ansible.builtin.apt:
    src: nginx
    state: present

# RIGHT
- ansible.builtin.apt:
    name: nginx
    state: present

Check valid parameters:

ansible-doc ansible.builtin.apt

JSON Parsing Error

"msg": "MODULE FAILURE: No start of json char found"

Your remote host is printing something before the module output. Common causes:

  • /etc/profile or .bashrc prints messages
  • MOTD or login banners
# Fix: set shell to non-interactive
- hosts: webservers
  vars:
    ansible_shell_type: sh

Permission Issues

- name: Task requiring root
  ansible.builtin.copy:
    src: config.conf
    dest: /etc/app/config.conf
  become: true  # Don't forget this!

Step 3: Test Module Directly

# Test a module in isolation
ansible webserver -m ansible.builtin.setup -a "filter=ansible_distribution" -vvv

# Test with a specific user
ansible webserver -m ansible.builtin.ping -u deploy --become -vvv

Step 4: Check Module Compatibility

# Verify the module exists
ansible-doc -l | grep module_name

# Check required collections
ansible-galaxy collection list

Conclusion

MODULE FAILURE almost always means a Python error on the remote host. Use -vvvv for the full traceback, check Python dependencies, and verify module arguments with ansible-doc.