mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #16641 from thatch45/rand_thin
Allows for the use or random thin dirs, fix #16308
This commit is contained in:
commit
cc4d877d5f
@ -16,6 +16,7 @@ import os
|
||||
import re
|
||||
import time
|
||||
import yaml
|
||||
import uuid
|
||||
|
||||
# Import salt libs
|
||||
import salt.client.ssh.shell
|
||||
@ -491,6 +492,8 @@ class Single(object):
|
||||
self.thin_dir = DEFAULT_THIN_DIR.replace('%%USER%%', user)
|
||||
else:
|
||||
self.thin_dir = DEFAULT_THIN_DIR.replace('%%USER%%', 'root')
|
||||
if self.opts.get('rand_thin_dir'):
|
||||
self.thin_dir = os.path.join('/tmp', '.{0}'.format(uuid.uuid4().hex))
|
||||
self.opts['_thin_dir'] = self.thin_dir
|
||||
self.fsclient = fsclient
|
||||
self.context = {'master_opts': self.opts,
|
||||
@ -718,6 +721,9 @@ class Single(object):
|
||||
debug = ''
|
||||
if salt.log.LOG_LEVELS['debug'] >= salt.log.LOG_LEVELS[self.opts['log_level']]:
|
||||
debug = '1'
|
||||
wipe = 'True' if self.opts.get('wipe_ssh') else 'False'
|
||||
if self.opts.get('rand_thin_dir'):
|
||||
wipe = 'True'
|
||||
arg_str = '''
|
||||
OPTIONS = OBJ()
|
||||
OPTIONS.config = '{0}'
|
||||
@ -735,7 +741,7 @@ ARGS = {8}\n'''.format(self.minion_config,
|
||||
'sha1',
|
||||
salt.__version__,
|
||||
self.mods.get('version', ''),
|
||||
'True' if self.opts.get('wipe_ssh') else 'False',
|
||||
wipe,
|
||||
self.argv)
|
||||
py_code = SSH_PY_SHIM.replace('#%%OPTS', arg_str)
|
||||
py_code_enc = py_code.encode('base64').replace('\n', '_')
|
||||
|
@ -2197,6 +2197,12 @@ class SaltSSHOptionParser(OptionParser, ConfigDirMixIn, MergeConfigMixIn,
|
||||
dest='wipe_ssh',
|
||||
help='Remove the deployment of the salt files when done executing.',
|
||||
)
|
||||
self.add_option(
|
||||
'--rand-thin-dir',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help=('Select a random temp dir to deploy on the remote system. '
|
||||
'The dir will be cleaned after the execution.'))
|
||||
|
||||
auth_group = optparse.OptionGroup(
|
||||
self, 'Authentication Options',
|
||||
|
Loading…
Reference in New Issue
Block a user