ansible/ansible · error · Exception
Something wrong with this module zip file: should not contai
Error message
Something wrong with this module zip file: should not contain absolute paths
What it means
Raised by the ansiballz self-extracting wrapper when the 'explode' debug command finds a zip entry whose name starts with '/'. The module package must contain only relative paths; an absolute entry indicates a corrupted, hand-edited, or incompatible ansiballz payload.
Source
Thrown at lib/ansible/_internal/_ansiballz/_wrapper.py:193
#
# You can now edit the source files to instrument the code or experiment with
# different parameter values. When you're ready to run the code you've modified
# (instead of the code from the actual zipped module), use the execute subcommand like this::
# $ /usr/bin/python /home/badger/.ansible/tmp/ansible-tmp-1461173013.93-9076457629738/ping execute
# Okay to use __file__ here because we're running from a kept file
basedir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'debug_dir')
args_path = os.path.join(basedir, 'args')
if command == 'explode':
# transform the ZIPDATA into an exploded directory of code and then
# print the path to the code. This is an easy way for people to look
# at the code on the remote machine for debugging it in that
# environment
z = zipfile.ZipFile(modlib_path)
for filename in z.namelist():
if filename.startswith('/'):
raise Exception('Something wrong with this module zip file: should not contain absolute paths')
dest_filename = os.path.join(basedir, filename)
if dest_filename.endswith(os.path.sep) and not os.path.exists(dest_filename):
os.makedirs(dest_filename)
else:
directory = os.path.dirname(dest_filename)
if not os.path.exists(directory):
os.makedirs(directory)
with open(dest_filename, 'wb') as writer:
writer.write(z.read(filename))
# write the args file
with open(args_path, 'wb') as writer:
writer.write(json_params)
print('Module expanded into:')
print(basedir)
View on GitHub (pinned to 9cf16a4aca)
Solutions
- Ensure controller and target run compatible ansible-core versions — regenerate the module by rerunning the task rather than reusing old kept files
- Delete stale remote tmp ansiballz files (find remote_tmp -name 'AnsiballZ_*' -delete) and retry with ANSIBLE_KEEP_REMOTE_FILES=1
- Verify the zip locally: python -c "import zipfile; print([n for n in zipfile.ZipFile('AnsiballZ_setup').namelist() if n.startswith('/')])"
- Check for transfer corruption: compare checksums of the module file on controller and target
Example fix
# before: stale/corrupt kept module
# ansible -m ping host -e ANSIBLE_KEEP_REMOTE_FILES=1, then rerun explode on old file
# after: clear kept files and regenerate
find "${TMPDIR:-/tmp}/ansible" -name 'AnsiballZ_*' -delete 2>/dev/null
ANSIBLE_KEEP_REMOTE_FILES=1 ansible host -m setup -a 'exploded_path=debug_dir' Defensive patterns
Strategy: validation
Validate before calling
import zipfile
names = zipfile.ZipFile(modlib_path).namelist()
bad = [n for n in names if n.startswith('/')]
if bad:
raise RuntimeError(f'corrupt ansiballz payload, absolute entries: {bad}') Try / catch
try:
wrapper_explode(payload)
except Exception as e:
if 'absolute paths' in str(e):
# stale/corrupt module package: purge kept files and re-transfer
shutil.rmtree(debug_dir, ignore_errors=True) Prevention
- Clear AnsiballZ_* files in remote_tmp when regenerating modules
- Keep controller and hosts on compatible ansible-core versions
- Verify module checksums after transfer on flaky links
When it happens
Trigger: Running the wrapped module with 'explode' (debugging with ANSIBLE_KEEP_REMOTE_FILES=1) on a zip that contains an absolute-path entry — typically a wrapper built by a different/broken ansible-core version or a payload truncated in transfer.
Common situations: Mismatched controller vs target ansible-core versions where the wrapper template changed; a partially transferred module zip (network truncation); manually repacking an ansiballz file with absolute names.
Related errors
- Unable to compile {module_name!r}.
- Failed to import packaging, check that a supported version i
- Neither python zipfile nor unzip can read %s
- Unable to list files in the archive
- string cannot be converted to a dict, must either be a JSON
AI-assisted analysis of ansible/ansible@9cf16a4aca (2026-08-15).
Data as JSON: /api/errors/35a3bb2b1d1a70c5.
Report an issue: GitHub.