CertGrid CertGrid
Hands-on Lab·Ansible

Ansible archive and unarchive Modules

unarchive is built in; archive is not - it lives in community.general, which is the kind of asymmetry that costs marks. Both turn out to be properly idempotent, including the one that writes a tarball, which is not what most people expect.

Automating Administration Guide 36 of 45 Intermediate

unarchive needs the matching tool on the target - tar for tarballs, unzip for zips. A zip extraction on a minimal image fails for a missing unzip, not for anything to do with Ansible.

Both managed nodes: ANS-A01 archives in place, ANS-B01 receives an archive from the control node.
Server NameIP AddressOSRolesCPURAMHDD
ANS-CTL01192.168.0.36Ubuntu 26.04 LTSAnsible Control Node2 Core3 GB50 GB
ANS-A01192.168.0.37Ubuntu 26.04 LTSManaged Node (group: web)2 Core3 GB50 GB
ANS-B01192.168.0.38Ubuntu 26.04 LTSManaged Node (group: db)2 Core3 GB50 GB

This guide includes

Use this when a directory has to be packaged or unpacked on a managed host. This matters because one of the two modules is built in and the other is not - and remote_src is what decides which machine the archive is read from.

Before you start

  1. The configuration this guide assumes

  2. Two modules, two collections

  3. Something to archive

  4. Archive it where it lives

  5. Run it again

  6. Unpack it on the same host

  7. The other direction: a file from the control node

  8. A zip, and what the target needs

  9. Put the hosts back

Official sources