1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix the error handling for loop squashing to restore the name argument into the task args

This commit is contained in:
Toshio Kuratomi 2016-05-21 07:06:01 -07:00
parent a0ff49194e
commit b75895df9b

View file

@ -269,6 +269,7 @@ class TaskExecutor:
Squash items down to a comma-separated list for certain modules which support it Squash items down to a comma-separated list for certain modules which support it
(typically package management modules). (typically package management modules).
''' '''
name = None
try: try:
# _task.action could contain templatable strings (via action: and # _task.action could contain templatable strings (via action: and
# local_action:) Template it before comparing. If we don't end up # local_action:) Template it before comparing. If we don't end up
@ -284,7 +285,6 @@ class TaskExecutor:
if all(isinstance(o, string_types) for o in items): if all(isinstance(o, string_types) for o in items):
final_items = [] final_items = []
name = None
for allowed in ['name', 'pkg', 'package']: for allowed in ['name', 'pkg', 'package']:
name = self._task.args.pop(allowed, None) name = self._task.args.pop(allowed, None)
if name is not None: if name is not None:
@ -326,6 +326,10 @@ class TaskExecutor:
except: except:
# Squashing is an optimization. If it fails for any reason, # Squashing is an optimization. If it fails for any reason,
# simply use the unoptimized list of items. # simply use the unoptimized list of items.
# Restore the name parameter
if name is not None:
self._task.args['name'] = name
pass pass
return items return items