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.

Luca Berton
4 min readSep 8, 2021

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.

--

--

Luca Berton
Luca Berton

Written by Luca Berton

I help creative Automation DevOps, Cloud Engineer, System Administrator, and IT Professional to succeed with Ansible Technology to automate more things everyday

No responses yet