mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
modules.archive: add opts arg to g(un)zip
This commit is contained in:
parent
c1219e68c5
commit
99bf89447b
@ -132,7 +132,7 @@ def tar(options, tarfile, sources=None, dest=None,
|
||||
|
||||
|
||||
@salt.utils.decorators.which('gzip')
|
||||
def gzip(sourcefile, template=None, runas=None):
|
||||
def gzip(sourcefile, template=None, runas=None, options=None):
|
||||
'''
|
||||
Uses the gzip command to create gzip files
|
||||
|
||||
@ -144,14 +144,27 @@ def gzip(sourcefile, template=None, runas=None):
|
||||
|
||||
salt '*' archive.gzip template=jinja /tmp/{{grains.id}}.txt
|
||||
|
||||
runas : None
|
||||
The user with which to run the gzip command line
|
||||
|
||||
options : None
|
||||
Pass any additional arguments to gzip
|
||||
|
||||
.. versionadded:: 2016.3.4
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Create /tmp/sourcefile.txt.gz
|
||||
salt '*' archive.gzip /tmp/sourcefile.txt
|
||||
salt '*' archive.gzip /tmp/sourcefile.txt options='-9 --verbose'
|
||||
'''
|
||||
cmd = ['gzip', '{0}'.format(sourcefile)]
|
||||
cmd = ['gzip']
|
||||
if options:
|
||||
cmd.append(options)
|
||||
cmd.append('{0}'.format(sourcefile))
|
||||
|
||||
return __salt__['cmd.run'](cmd,
|
||||
template=template,
|
||||
runas=runas,
|
||||
@ -159,7 +172,7 @@ def gzip(sourcefile, template=None, runas=None):
|
||||
|
||||
|
||||
@salt.utils.decorators.which('gunzip')
|
||||
def gunzip(gzipfile, template=None, runas=None):
|
||||
def gunzip(gzipfile, template=None, runas=None, options=None):
|
||||
'''
|
||||
Uses the gunzip command to unpack gzip files
|
||||
|
||||
@ -171,14 +184,27 @@ def gunzip(gzipfile, template=None, runas=None):
|
||||
|
||||
salt '*' archive.gunzip template=jinja /tmp/{{grains.id}}.txt.gz
|
||||
|
||||
runas : None
|
||||
The user with which to run the gzip command line
|
||||
|
||||
options : None
|
||||
Pass any additional arguments to gzip
|
||||
|
||||
.. versionadded:: 2016.3.4
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Create /tmp/sourcefile.txt
|
||||
salt '*' archive.gunzip /tmp/sourcefile.txt.gz
|
||||
salt '*' archive.gunzip /tmp/sourcefile.txt options='--verbose'
|
||||
'''
|
||||
cmd = ['gunzip', '{0}'.format(gzipfile)]
|
||||
cmd = ['gunzip']
|
||||
if options:
|
||||
cmd.append(options)
|
||||
cmd.append('{0}'.format(gzipfile))
|
||||
|
||||
return __salt__['cmd.run'](cmd,
|
||||
template=template,
|
||||
runas=runas,
|
||||
|
Loading…
Reference in New Issue
Block a user