Ansible Error: 'unarchive Failed to find handler ... make sure the required command to extract the file is installed' — Cause, Fix, and Troubleshooting Guide
Fix Ansible unarchive 'Failed to find handler ... make sure the required command to extract the file is installed': install unzip/tar and check the archive.
- #ansible
- #troubleshooting
- #automation
- #modules
Stuck on this Ansible error? Get the free incident triage checklist
A one-page PDF — the exact steps to isolate, fix, and verify a production error like this one. No spam, unsubscribe anytime.
Overview
The unarchive module hands extraction off to a command on the target host — tar, gtar, unzip, or zipinfo depending on the archive format. If the right binary is missing on the managed node, the module cannot pick a handler:
fatal: [web-01]: FAILED! => {"changed": false, "msg": "Failed to find handler for '/tmp/app.zip'. Make sure the required command to extract the file is installed.\nCommand \"/usr/bin/unzip\" could not handle archive: /usr/bin/unzip not found\nCommand \"/usr/bin/zipinfo\" could not handle archive."}
The message lists each handler it tried and why each failed — usually a missing unzip.
Symptoms
unarchivefails on a fresh/minimal host (containers, cloud base images)..zipfiles fail while.tar.gzworks, or vice versa.- The message names specific commands (
unzip,zipinfo,gtar) that “could not handle” the archive.
ansible-playbook -i inventory.ini deploy.yml
TASK [Extract release] ******
fatal: [web-01]: FAILED! => {"msg": "Failed to find handler for '/tmp/release.zip'. Make sure the required command to extract the file is installed."}
Common Root Causes
1. unzip not installed (most common for .zip)
Minimal images often ship without unzip; the module has no way to open a zip.
2. tar/gtar missing or non-GNU
Some archives need GNU tar features; a BusyBox/BSD tar can fail to handle them.
3. Corrupt or wrong-type archive
The file is not actually the format its extension claims (truncated download, HTML error page saved as .zip).
4. Extracting on the controller vs target confusion
remote_src: false copies then extracts on the target; the handler still needs to exist on the target.
How to diagnose
Check for the extractor on the target:
ansible web-01 -i inventory.ini -m shell -a 'command -v unzip tar gtar; file /tmp/release.zip'
Verify the archive is valid:
ansible web-01 -i inventory.ini -m shell -a 'unzip -l /tmp/release.zip || tar -tzf /tmp/release.tgz'
Fixes
Install the extractor as a dependency
- name: Ensure unzip is present
ansible.builtin.package:
name: unzip
state: present
- name: Extract release
ansible.builtin.unarchive:
src: release.zip
dest: /opt/app
remote_src: false
For tar-based archives on minimal hosts:
- name: Ensure tar/gzip
ansible.builtin.package:
name:
- tar
- gzip
state: present
Re-fetch a possibly-corrupt archive
- name: Download release with checksum
ansible.builtin.get_url:
url: https://example.com/release.zip
dest: /tmp/release.zip
checksum: "sha256:{{ release_sha256 }}"
What to watch out for
- Order matters: install
unzip/tarin an earlier task (or role dependency) before theunarchivetask runs. get_url+checksumprevents extracting a truncated download that fails as “cannot handle archive.”- In containers, prefer building the artifact in during image build; runtime extraction adds a package dependency to every base image.
Related
- Ansible Error: ‘No package matching found available’
- Ansible Error: ‘Could not find or access file on the Ansible Controller’
- Ansible Error: command not found / No such file or directory
Fixed it? Get 500 Ansible & DevOps AI prompts — free
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.
Stuck on this? Start guided troubleshooting
Open an interactive diagnostic session with this error already loaded. Work a step-by-step plan, record what each check returns, land on a root cause, and export a clean incident summary — no account needed to start.
Did this fix your issue?
Solved it a different way?
Share the fix that worked for you — reviewed, then published to help the next engineer.
That looks like it may contain a secret (key, token, password, or connection string). Please remove it — a note with a detected secret can’t be published.
Thanks — that helps. Published notes appear after a quick review.
More Ansible prompts & error guides
Every Ansible AI prompt and troubleshooting guide, in one place.
Trending errors this week
The error guides other engineers are actually reading right now.
- 1mount: wrong fs type, bad option, bad superblock
- 2Docker 'failed to set up container networking': Fix the Bridge and IP Pool
- 3Docker 'failed to create shim task': How to Fix the containerd Runtime Error
- 4Transport endpoint is not connected
- 5modprobe: FATAL: Module not found
- 6mount: wrong fs type, bad option, bad superblock
Get 500 Battle-Tested DevOps AI Prompts — Free
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.