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).

archive.gzip

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

archive.gunzip

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

archive.rar

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

archive.unrar

Uses the unrar command to unpack rar files.

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

archive.tar

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

archive.zip

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

salt '*' archive.zip /tmp/zipfile.zip /tmp/file1 /tmp/file2

archive.unzip

Uses the unzip command to unpack zip files.

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