mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
Get warnings/deprecations per item in loop
warnings and deprecations were only returned for the top level of a task, this now deals with them in loop deduplication still occurs so only unique ones will be shown to user. fixes #25258
This commit is contained in:
parent
90b1d780eb
commit
13d3b27a0a
1 changed files with 19 additions and 19 deletions
|
@ -34,7 +34,6 @@ from ansible.plugins.connection import ConnectionBase
|
||||||
from ansible.template import Templar
|
from ansible.template import Templar
|
||||||
from ansible.utils.encrypt import key_for_hostname
|
from ansible.utils.encrypt import key_for_hostname
|
||||||
from ansible.utils.listify import listify_lookup_plugin_terms
|
from ansible.utils.listify import listify_lookup_plugin_terms
|
||||||
from ansible.utils.ssh_functions import check_for_controlpersist
|
|
||||||
from ansible.utils.unsafe_proxy import UnsafeProxy, wrap_var
|
from ansible.utils.unsafe_proxy import UnsafeProxy, wrap_var
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -96,27 +95,28 @@ class TaskExecutor:
|
||||||
if len(items) > 0:
|
if len(items) > 0:
|
||||||
item_results = self._run_loop(items)
|
item_results = self._run_loop(items)
|
||||||
|
|
||||||
# loop through the item results, and remember the changed/failed
|
# create the overall result item
|
||||||
# result flags based on any item there.
|
|
||||||
changed = False
|
|
||||||
failed = False
|
|
||||||
for item in item_results:
|
|
||||||
if 'changed' in item and item['changed']:
|
|
||||||
changed = True
|
|
||||||
if 'failed' in item and item['failed']:
|
|
||||||
failed = True
|
|
||||||
|
|
||||||
# create the overall result item, and set the changed/failed
|
|
||||||
# flags there to reflect the overall result of the loop
|
|
||||||
res = dict(results=item_results)
|
res = dict(results=item_results)
|
||||||
|
|
||||||
if changed:
|
# loop through the item results, and set the global changed/failed result flags based on any item.
|
||||||
res['changed'] = True
|
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'):
|
||||||
|
res['failed'] = True
|
||||||
|
res['msg'] = 'One or more items failed'
|
||||||
|
|
||||||
if failed:
|
# ensure to accumulate these
|
||||||
res['failed'] = True
|
for array in ['warnings', 'deprecations']:
|
||||||
res['msg'] = 'One or more items failed'
|
if array in item and item[array]:
|
||||||
else:
|
if array not in res:
|
||||||
|
res[array] = []
|
||||||
|
if not isinstance(item[array], list):
|
||||||
|
item[array] = [item[array]]
|
||||||
|
res[array] = res[array] + item[array]
|
||||||
|
del item[array]
|
||||||
|
|
||||||
|
if not res.get('Failed', False):
|
||||||
res['msg'] = 'All items completed'
|
res['msg'] = 'All items completed'
|
||||||
else:
|
else:
|
||||||
res = dict(changed=False, skipped=True, skipped_reason='No items in the list', results=[])
|
res = dict(changed=False, skipped=True, skipped_reason='No items in the list', results=[])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue