Ansible unarchive module is used to unpack or uncompressed the files from an archive file such as zip, tar, tar.gz. It can optionally copy the files to the remote server before uncompressing them.
The unarchive module uses the basic unzip and tar -xvf command-line tools to operate. So the target server must have installed these commands. Since most of the *nix distributions are in-built these tools. Here are some essential points of Ansible unarchive, such as:
Why Use Unarchive Module
The Ansible Unarchive module is useful for moving large files and folders across host machines.
For example, if you have a bunch of NGINX configuration files, you can use the unarchive command to download a zipped folder from a URL and unzip it.
1. Extract foo.tgz into /var/lib/foo as shown in the following code, such as:
2. To unarchive a file that is already on the remote machine:
3. To unarchive a file that needs to be downloaded:
4. To unarchive a file with extra options