Ensure loop with delegate_to can short circuit the same as without delegate_to. Fixes #45189 (#45231)

This commit is contained in:
Matt Martz
2018-09-07 10:16:03 -05:00
committed by GitHub
parent 9a76441c02
commit 2ac647def8
3 changed files with 29 additions and 1 deletions

View File

@@ -512,7 +512,12 @@ class VariableManager:
else:
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)
try:
items = templar.template(task.loop)
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:
has_loop = False
items = [None]