Extract an archive
New in version 2014.1.0.
salt.states.archive.
extracted
(name, source, archive_format, archive_user=None, password=None, user=None, group=None, tar_options=None, source_hash=None, if_missing=None, keep=False, trim_output=False, skip_verify=False, source_hash_update=None)¶New in version 2014.1.0.
State that make sure an archive is extracted in a directory. The downloaded archive is erased if successfully extracted. The archive is downloaded only if necessary.
Note
If if_missing
is not defined, this state will check for name
instead. If name
exists, it will assume the archive was previously
extracted successfully and will not extract it again.
Example, tar with flag for lmza compression:
graylog2-server:
archive.extracted:
- name: /opt/
- source: https://github.com/downloads/Graylog2/graylog2-server/graylog2-server-0.9.6p1.tar.lzma
- source_hash: md5=499ae16dcae71eeb7c3a30c75ea7a1a6
- tar_options: J
- archive_format: tar
- if_missing: /opt/graylog2-server-0.9.6p1/
Example, tar with flag for verbose output:
graylog2-server:
archive.extracted:
- name: /opt/
- source: https://github.com/downloads/Graylog2/graylog2-server/graylog2-server-0.9.6p1.tar.gz
- source_hash: md5=499ae16dcae71eeb7c3a30c75ea7a1a6
- archive_format: tar
- tar_options: v
- user: root
- group: root
- if_missing: /opt/graylog2-server-0.9.6p1/
Example, tar with flag for lmza compression and update based if source_hash differs from what was previously extracted:
graylog2-server:
archive.extracted:
- name: /opt/
- source: https://github.com/downloads/Graylog2/graylog2-server/graylog2-server-0.9.6p1.tar.lzma
- source_hash: md5=499ae16dcae71eeb7c3a30c75ea7a1a6
- source_hash_update: true
- tar_options: J
- archive_format: tar
- if_missing: /opt/graylog2-server-0.9.6p1/
Password to use with password protected zip files. Currently only zip files with passwords are supported.
New in version 2016.3.0.
Set this to True
if archive should be extracted if source_hash has
changed. This would extract regardless of the if_missing
parameter.
New in version 2016.3.0.
If True
, hash verification of remote file sources (http://
,
https://
, ftp://
) will be skipped, and the source_hash
argument will be ignored.
New in version 2016.3.4.
tar
, zip
or rar
The user to own each extracted file.
Deprecated since version 2014.7.2: Replaced by user
parameter
The user to own each extracted file.
New in version 2015.8.0.
Changed in version 2016.3.0: When used in combination with if_missing
, ownership will only
be enforced if if_missing
is a directory.
The group to own each extracted file.
New in version 2015.8.0.
Changed in version 2016.3.0: When used in combination with if_missing
, ownership will only
be enforced if if_missing
is a directory.
If specified, this path will be checked, and if it exists then the archive will not be extracted. This can be helpful if the archive extracts all files into a subfolder. This path can be either a directory or a file, so this option can also be used to check for a semaphore file and conditionally skip extraction.
Changed in version 2016.3.0: When used in combination with either user
or group
,
ownership will only be enforced when if_missing
is a directory.
If archive_format
is set to tar
, this option can be used to
specify a string of additional arguments to pass to the tar command. If
archive_format
is set to tar
and this option is not used,
then the minion will attempt to use Python's native tarfile support to
extract it. Python's native tarfile support can only handle gzip and
bzip2 compression, however.
Changed in version 2015.8.11,2016.3.2: XZ-compressed archives no longer require J
to manually be set
in the tar_options
, they are now detected automatically and
Salt will extract them using xz-utils
. This is a more
platform-independent solution, as not all tar implementations
support the J
argument for extracting archives.
Note
Main operators like -x, --extract, --get, -c and -f/--file should not be used here.
Using this option means that the tar
command will be used,
which is less platform-independent, so keep this in mind when using
this option; the options must be valid options for the tar
implementation on the minion's OS.
The number of files we should output on success before the rest are trimmed, if this is set to True then it will default to 100
New in version 2016.3.0.