AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,100 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example" published by Apress, and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

Ansible unarchive Module: Extract tar, zip, gz Archives (Complete Guide)

By Luca Berton · Published 2024-01-01 · Category: installation

How to use Ansible unarchive module to extract tar.gz, zip, bz2 archives. Deploy from local or remote sources. Complete guide with playbook examples.

Ansible unarchive Module: Extract tar, zip, gz Archives (Complete Guide)

The ansible.builtin.unarchive module unpack compressed archives on remote hosts. This guide covers all common use cases with practical playbook examples.

Extract Local Archive to Remote Host

Extract Remote Archive

Extract with Specific Options

Extract zip File

FAQ

How do I extract a tar.gz file in Ansible?

Use ansible.builtin.unarchive with src (archive path) and dest (target directory). Add remote_src: true if the archive is already on the remote host.

Can Ansible download and extract an archive in one step?

Yes. Set src to an HTTP/HTTPS URL and remote_src: true. Ansible downloads and extracts in one task. Use creates to skip if already extracted.

What archive formats does unarchive support?

Ansible unarchive supports tar, tar.gz, tar.bz2, tar.xz, zip, and gz. The remote host needs the appropriate tools installed (tar, unzip, gzip, bzip2, xz).

Conclusion

The ansible.builtin.unarchive module is a versatile tool for unpack compressed archives on remote hosts. Use the examples above as starting points and adapt them to your infrastructure needs.

Related ArticlesAnsible copy Module: Copy Files to HostsAnsible get_url: Download Files

Category: installation

Browse all Ansible tutorials · AnsiblePilot Home