Allow any_errors_fatal to be dynamic
Currently any_errors_fatal cannot be dynamic value based on the current
task vars. This change attempts to evaulate the provided value and
verifies it's a boolean when using it to handle the any_errors_fatal
logic.
Related Upstream: https://github.com/ansible/ansible/pull/70694
Related-Bug: #1887702
Change-Id: I31cf042b72aad5cdd2c7c1ae8bc319eca372acff
(cherry picked from commit 28d4e52a16
)
This commit is contained in:
parent
9bbc827152
commit
b47a4a7679
|
@ -129,6 +129,14 @@ class TripleoBase(StrategyBase):
|
||||||
failures[role] = 1
|
failures[role] = 1
|
||||||
return failures
|
return failures
|
||||||
|
|
||||||
|
def _get_task_errors_fatal(self, task, templar):
|
||||||
|
"""Return parsed any_errors_fatal from a task"""
|
||||||
|
return task.get_validated_value('any_errors_fatal',
|
||||||
|
task._valid_attrs['any_errors_fatal'],
|
||||||
|
templar.template(
|
||||||
|
task.any_errors_fatal),
|
||||||
|
None)
|
||||||
|
|
||||||
def process_includes(self, host_results, noop=False):
|
def process_includes(self, host_results, noop=False):
|
||||||
"""Handle includes
|
"""Handle includes
|
||||||
|
|
||||||
|
|
|
@ -229,7 +229,7 @@ class StrategyModule(BASE.TripleoBase):
|
||||||
self._blocked_hosts[host_name] = False
|
self._blocked_hosts[host_name] = False
|
||||||
else:
|
else:
|
||||||
if not self._step or self._take_step(task, host_name):
|
if not self._step or self._take_step(task, host_name):
|
||||||
if task.any_errors_fatal:
|
if self._get_task_errors_fatal(task, templar):
|
||||||
display.warning('any_errors_fatal only stops any future '
|
display.warning('any_errors_fatal only stops any future '
|
||||||
'tasks running on the host that fails '
|
'tasks running on the host that fails '
|
||||||
'with the tripleo_free strategy.')
|
'with the tripleo_free strategy.')
|
||||||
|
|
|
@ -216,18 +216,6 @@ class StrategyModule(BASE.TripleoBase):
|
||||||
and not task._role._metadata.allow_duplicates):
|
and not task._role._metadata.allow_duplicates):
|
||||||
raise TripleoLinearNoHostTask()
|
raise TripleoLinearNoHostTask()
|
||||||
|
|
||||||
if task.action == 'meta':
|
|
||||||
results.extend(self._execute_meta(task,
|
|
||||||
self._play_context,
|
|
||||||
self._iterator,
|
|
||||||
host))
|
|
||||||
if (task.args.get('_raw_params', None) not in ('noop',
|
|
||||||
'reset_connection',
|
|
||||||
'end_host')):
|
|
||||||
run_once = True
|
|
||||||
if (task.any_errors_fatal or run_once and not task.ignore_errors):
|
|
||||||
self._any_errors_fatal = True
|
|
||||||
else:
|
|
||||||
# todo handle steps like in linear
|
# todo handle steps like in linear
|
||||||
# build get_vars call params
|
# build get_vars call params
|
||||||
vars_params = {'play': self._iterator._play,
|
vars_params = {'play': self._iterator._play,
|
||||||
|
@ -246,6 +234,20 @@ class StrategyModule(BASE.TripleoBase):
|
||||||
|
|
||||||
run_once = (templar.template(task.run_once) or action
|
run_once = (templar.template(task.run_once) or action
|
||||||
and getattr(action, 'BYPASS_HOST_LOOP', False))
|
and getattr(action, 'BYPASS_HOST_LOOP', False))
|
||||||
|
|
||||||
|
if task.action == 'meta':
|
||||||
|
results.extend(self._execute_meta(task,
|
||||||
|
self._play_context,
|
||||||
|
self._iterator,
|
||||||
|
host))
|
||||||
|
if (task.args.get('_raw_params', None) not in ('noop',
|
||||||
|
'reset_connection',
|
||||||
|
'end_host')):
|
||||||
|
run_once = True
|
||||||
|
if (self._get_task_errors_fatal(task, templar)
|
||||||
|
or run_once and not task.ignore_errors):
|
||||||
|
self._any_errors_fatal = True
|
||||||
|
else:
|
||||||
self._send_task_callback(task, templar)
|
self._send_task_callback(task, templar)
|
||||||
self._blocked_hosts[host.get_name()] = True
|
self._blocked_hosts[host.get_name()] = True
|
||||||
self._queue_task(host, task, task_vars, self._play_context)
|
self._queue_task(host, task, task_vars, self._play_context)
|
||||||
|
|
Loading…
Reference in New Issue