Member-only story
Extract an archive — Ansible module unarchive
Live console coding how to download a zip file and extract in a user home directory. The playbook is also taking care of the necessary dependencies.
How to extract an archive in Ansible?
I’m going to show you a live demo and some simple Ansible code.
I’m Luca Berton and welcome to today’s episode of Ansible Pilot.
Ansible extract an archive
Today we’re talking about the Ansible module `unarchive`.
The full name is `ansible.builtin.unarchive`, which means that is part of the collection of modules “builtin” with ansible and shipped with it.
It’s a module pretty stable and out for years.
It works in a different variety of operating systems.
It unpacks one archive after (optionally) copying it from the local machine
It can handle `.zip` files using `unzip` as well as `.tar`, `.tar.gz`, `.tar.bz2`, `.tar.xz`, and `.tar.zst` files using `gtar`. It requires `zipinfo`,`gtar` and `unzip` command on target host.