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
This commit is contained in:
Alex Schultz 2020-07-16 13:44:03 -06:00
parent 0d9effda37
commit 28d4e52a16
3 changed files with 30 additions and 20 deletions

View File

@ -127,6 +127,14 @@ class TripleoBase(StrategyBase):
failures[role] = 1
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):
"""Handle includes

View File

@ -227,7 +227,7 @@ class StrategyModule(BASE.TripleoBase):
self._blocked_hosts[host_name] = False
else:
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 '
'tasks running on the host that fails '
'with the tripleo_free strategy.')

View File

@ -214,18 +214,6 @@ class StrategyModule(BASE.TripleoBase):
and not task._role._metadata.allow_duplicates):
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
# build get_vars call params
vars_params = {'play': self._iterator._play,
@ -244,6 +232,20 @@ class StrategyModule(BASE.TripleoBase):
run_once = (templar.template(task.run_once) or action
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._blocked_hosts[host.get_name()] = True
self._queue_task(host, task, task_vars, self._play_context)