salt.states.archive

Extract an archive

2014.1.0 新版功能.

salt.states.archive.compareChecksum(fname, target, checksum)
salt.states.archive.extracted(name, source, archive_format, archive_user=None, password=None, user=None, group=None, tar_options=None, zip_options=None, source_hash=None, if_missing=None, keep=False, trim_output=False, source_hash_update=None)

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.

注解

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/
name
Directory name where to extract the archive
password

Password to use with password protected zip files. Currently only zip files with passwords are supported.

2016.3.0 新版功能.

source
Archive source, same syntax as file.managed source argument.
source_hash
Hash of source file, or file with list of hash-to-file mappings. It uses the same syntax as the file.managed source_hash argument.
source_hash_update
Set this to true if archive should be extracted if source_hash has changed. This would extract regardless of the if_missing parameter.
archive_format
tar, zip or rar
user

The user to own each extracted file.

2015.8.0 新版功能.

group

The group to own each extracted file.

2015.8.0 新版功能.

if_missing
Some archives, such as tar, extract themselves in a subfolder. This directive can be used to validate if the archive had been previously extracted.
tar_options
Required if used with archive_format: tar, otherwise optional. It needs to be the tar argument specific to the archive being extracted, such as 'J' for LZMA or 'v' to verbosely list files processed. Using this option means that the tar executable on the target will be used, which is less platform independent. Main operators like -x, --extract, --get, -c and -f/--file should not be used here. If archive_format is zip or rar and this option is not set, then the Python tarfile module is used. The tarfile module supports gzip and bz2 in Python 2.
zip_options

Optional when using zip archives, ignored when usign other archives files. This is mostly used to overwrite exsiting files with o. This options are only used when unzip binary is used.

2016.3.1 新版功能.

keep
Keep the archive in the minion's cache
trim_output
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
salt.states.archive.updateChecksum(fname, target, checksum)