summaryrefslogtreecommitdiff
path: root/lib/ansible/executor
diff options
context:
space:
mode:
authorBrian Coca <brian.coca+git@gmail.com>2016-03-01 15:11:04 -0500
committerBrian Coca <brian.coca+git@gmail.com>2016-03-01 15:11:34 -0500
commit71402abf2162f951000e1ce8e5210f39a602bf6d (patch)
treea7543ec994126055a0d904b342656780056b05aa /lib/ansible/executor
parent18240d350c36a80318ba05cd4db3d86d9ed5d0f8 (diff)
downloadansible-71402abf2162f951000e1ce8e5210f39a602bf6d.tar.gz
only do squash when 'squashable field' present
Diffstat (limited to 'lib/ansible/executor')
-rw-r--r--lib/ansible/executor/task_executor.py47
1 files changed, 24 insertions, 23 deletions
diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py
index b59295b0ed..a0881cc222 100644
--- a/lib/ansible/executor/task_executor.py
+++ b/lib/ansible/executor/task_executor.py
@@ -279,29 +279,30 @@ class TaskExecutor:
# This gets the information to check whether the name field
# contains a template that we can squash for
template_no_item = template_with_item = None
- if templar._contains_vars(name):
- variables['item'] = '\0$'
- template_no_item = templar.template(name, variables, cache=False)
- variables['item'] = '\0@'
- template_with_item = templar.template(name, variables, cache=False)
- del variables['item']
-
- # Check if the user is doing some operation that doesn't take
- # name/pkg or the name/pkg field doesn't have any variables
- # and thus the items can't be squashed
- if name and (template_no_item != template_with_item):
- for item in items:
- variables['item'] = item
- if self._task.evaluate_conditional(templar, variables):
- new_item = templar.template(name, cache=False)
- final_items.append(new_item)
- self._task.args['name'] = final_items
- # Wrap this in a list so that the calling function loop
- # executes exactly once
- return [final_items]
- else:
- # Restore the name parameter
- self._task.args['name'] = name
+ if name:
+ if templar._contains_vars(name):
+ variables['item'] = '\0$'
+ template_no_item = templar.template(name, variables, cache=False)
+ variables['item'] = '\0@'
+ template_with_item = templar.template(name, variables, cache=False)
+ del variables['item']
+
+ # Check if the user is doing some operation that doesn't take
+ # name/pkg or the name/pkg field doesn't have any variables
+ # and thus the items can't be squashed
+ if template_no_item != template_with_item:
+ for item in items:
+ variables['item'] = item
+ if self._task.evaluate_conditional(templar, variables):
+ new_item = templar.template(name, cache=False)
+ final_items.append(new_item)
+ self._task.args['name'] = final_items
+ # Wrap this in a list so that the calling function loop
+ # executes exactly once
+ return [final_items]
+ else:
+ # Restore the name parameter
+ self._task.args['name'] = name
#elif:
# Right now we only optimize single entries. In the future we
# could optimize more types: