Keep your minions happy with tips from Into The Salt Mine

Introduction to SaltStacks archive module

Salt provides an archive module for working with different types of file archives. This includes gunzip, gzip, rar, unrar, tar, unzip, and zip. The examples below demonstrate usage examples for each of these archive types.

This module is supported on POSIX-like systems, and only for the archive tyes installed on the minion(s).


Uses the gzip command to create gzip files.

To compress /tmp/file.txt and create /tmp/file.txt.gz:

salt '*' archive.gzip /tmp/file.txt


Uses the gunzip command to unpack gzip files.

To extract /tmp/file.txt.gz and create /tmp/file.txt:

salt '*' archive.gunzip /tmp/file.txt.gz


Uses the rar command to create rar files.

To create /tmp/rarfile.rar from the files /tmp/file1 and /tmp/file2:

salt '*' archive.rar /tmp/rarfile.rar /tmp/file1 /tmp/file2


Uses the unrar command to unpack rar files.

salt '*' archive.unrar /tmp/rarfile.rar /tmp/destination/


Uses the tar command to pack, unpack, etc tar files.

This function allows you to specify the tar options manually, giving you added flexibility when working with tar archives.

salt '*' archive.tar cjf /tmp/tarfile.tar.bz2 /tmp/file1 /tmp/file2

Uses the zip command to create zip files. To create /tmp/ from /tmp/file1 and /tmp/file2:

salt '*' /tmp/ /tmp/file1 /tmp/file2


Uses the unzip command to unpack zip files.

salt '*' archive.unzip /tmp/ /tmp/destination/
comments powered by Disqus