Made batch work properly with failhard in cli and runner

This commit is contained in:
Proskurin Kirill 2019-09-29 23:56:59 +01:00
parent b9459e6a96
commit 2416516ddc
No known key found for this signature in database
GPG key ID: C37A1DDDB950E71D
3 changed files with 23 additions and 1 deletions

View file

@ -254,6 +254,9 @@ class Batch(object):
data['ret']['retcode'] = data['retcode']
if self.opts.get('failhard') and data['ret']['retcode'] > 0:
failhard = True
else:
if self.opts.get('failhard') and data['retcode'] > 0:
failhard = True
if self.opts.get('raw'):
ret[minion] = data

View file

@ -547,7 +547,7 @@ class LocalClient(object):
'tgt_type': tgt_type,
'ret': ret,
'batch': batch,
'failhard': kwargs.get('failhard', False),
'failhard': kwargs.get('failhard', self.opts.get('failhard', False)),
'raw': kwargs.get('raw', False)}
if 'timeout' in kwargs:

View file

@ -128,6 +128,7 @@ def state(name,
queue=False,
subset=None,
orchestration_jid=None,
failhard=None,
**kwargs):
'''
Invoke a state run on a given target
@ -221,6 +222,11 @@ def state(name,
.. versionadded:: 2017.7.0
failhard
pass failhard down to the executing state
.. versionadded:: 2019.2.2
Examples:
Run a list of sls files via :py:func:`state.sls <salt.state.sls>` on target
@ -311,9 +317,13 @@ def state(name,
if batch is not None:
cmd_kw['batch'] = six.text_type(batch)
if subset is not None:
cmd_kw['subset'] = subset
if failhard is True or __opts__.get('failhard'):
cmd_kw['failhard'] = True
masterless = __opts__['__role'] == 'minion' and \
__opts__['file_client'] == 'local'
if not masterless:
@ -428,6 +438,7 @@ def function(
timeout=None,
batch=None,
subset=None,
failhard=None,
**kwargs): # pylint: disable=unused-argument
'''
Execute a single module function on a remote minion via salt or salt-ssh
@ -477,6 +488,11 @@ def function(
.. versionadded:: 2017.7.0
failhard
pass failhard down to the executing state
.. versionadded:: 2019.2.2
'''
func_ret = {'name': name,
'changes': {},
@ -502,6 +518,9 @@ def function(
cmd_kw['expect_minions'] = expect_minions
cmd_kw['_cmd_meta'] = True
if failhard is True or __opts__.get('failhard'):
cmd_kw['failhard'] = True
if ret_config:
cmd_kw['ret_config'] = ret_config