From 341db894f54dfcaf2d50b000a102822bd3203dbb Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 12 Oct 2017 14:57:38 -0400 Subject: [PATCH] update delegated var fetching for new 'loop' (#31588) * update delegated var fetching for new 'loop' * mixed loop/terms --- lib/ansible/vars/manager.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/ansible/vars/manager.py b/lib/ansible/vars/manager.py index 4f5e6668802..5f27051917e 100644 --- a/lib/ansible/vars/manager.py +++ b/lib/ansible/vars/manager.py @@ -519,18 +519,20 @@ class VariableManager: templar = Templar(loader=self._loader, variables=vars_copy) items = [] - if task.loop is not None: - if task.loop in lookup_loader: + if task.loop_with is not None: + if task.loop_with in lookup_loader: try: loop_terms = listify_lookup_plugin_terms(terms=task.loop, templar=templar, loader=self._loader, fail_on_undefined=True, convert_bare=False) - items = lookup_loader.get(task.loop, loader=self._loader, templar=templar).run(terms=loop_terms, variables=vars_copy) + items = lookup_loader.get(task.loop_with, loader=self._loader, templar=templar).run(terms=loop_terms, variables=vars_copy) except AnsibleUndefinedVariable: # This task will be skipped later due to this, so we just setup # a dummy array for the later code so it doesn't fail items = [None] else: - raise AnsibleError("Unexpected failure in finding the lookup named '%s' in the available lookup plugins" % task.loop) + raise AnsibleError("Failed to find the lookup named '%s' in the available lookup plugins" % task.loop_with) + elif task.loop is not None: + items = templar.template(task.loop) else: items = [None]