From 3bef1078723fe2264494880835ed76f795421a11 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Sat, 21 May 2016 07:34:36 -0700 Subject: [PATCH] Fix the error handling for loop squashing to restore the name argument into the task args (#15949) --- lib/ansible/executor/task_executor.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py index 04ea22a02e..f35ba897f1 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -269,6 +269,7 @@ class TaskExecutor: Squash items down to a comma-separated list for certain modules which support it (typically package management modules). ''' + name = None try: # _task.action could contain templatable strings (via action: and # 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): final_items = [] - name = None for allowed in ['name', 'pkg', 'package']: name = self._task.args.pop(allowed, None) if name is not None: @@ -326,6 +326,10 @@ class TaskExecutor: except: # Squashing is an optimization. If it fails for any reason, # simply use the unoptimized list of items. + + # Restore the name parameter + if name is not None: + self._task.args['name'] = name pass return items