mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
handle ignore_errors in loop
ensures we get both a templated ignore_errors and a correct 'summary' result for ignore_errors when used in loops fixes #32384
This commit is contained in:
parent
680d06d1ab
commit
d22627d944
1 changed files with 11 additions and 4 deletions
|
@ -100,9 +100,14 @@ class TaskExecutor:
|
|||
for item in item_results:
|
||||
if 'changed' in item and item['changed'] and not res.get('changed'):
|
||||
res['changed'] = True
|
||||
if 'failed' in item and item['failed'] and not res.get('failed'):
|
||||
if 'failed' in item and item['failed']:
|
||||
item_ignore = item.pop('_ansible_ignore_errors')
|
||||
if not res.get('failed'):
|
||||
res['failed'] = True
|
||||
res['msg'] = 'One or more items failed'
|
||||
self._task.ignore_errors = item_ignore
|
||||
elif self._task.ignore_errors and not item_ignore:
|
||||
self._task.ignore_errors = item_ignore
|
||||
|
||||
# ensure to accumulate these
|
||||
for array in ['warnings', 'deprecations']:
|
||||
|
@ -295,6 +300,7 @@ class TaskExecutor:
|
|||
(self._task, tmp_task) = (tmp_task, self._task)
|
||||
(self._play_context, tmp_play_context) = (tmp_play_context, self._play_context)
|
||||
res = self._execute(variables=task_vars)
|
||||
task_fields = self._task.dump_attrs()
|
||||
(self._task, tmp_task) = (tmp_task, self._task)
|
||||
(self._play_context, tmp_play_context) = (tmp_play_context, self._play_context)
|
||||
|
||||
|
@ -302,6 +308,7 @@ class TaskExecutor:
|
|||
# to the list of results
|
||||
res[loop_var] = item
|
||||
res['_ansible_item_result'] = True
|
||||
res['_ansible_ignore_errors'] = task_fields.get('ignore_errors')
|
||||
|
||||
if label is not None:
|
||||
templar = Templar(loader=self._loader, shared_loader_obj=self._shared_loader_obj, variables=self._job_vars)
|
||||
|
@ -312,7 +319,7 @@ class TaskExecutor:
|
|||
self._host.name,
|
||||
self._task._uuid,
|
||||
res,
|
||||
task_fields=self._task.dump_attrs(),
|
||||
task_fields=task_fields,
|
||||
),
|
||||
block=False,
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue