mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
update delegated var fetching for new 'loop' (#31588)
* update delegated var fetching for new 'loop' * mixed loop/terms
This commit is contained in:
parent
840a57a4ed
commit
341db894f5
1 changed files with 6 additions and 4 deletions
|
@ -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]
|
||||
|
||||
|
|
Loading…
Reference in a new issue