mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
For with_first_found loops, set undefined variables to fall through rather than failing the task
This commit is contained in:
parent
317e908165
commit
1a04f354f3
1 changed files with 15 additions and 8 deletions
|
@ -167,6 +167,13 @@ class TaskExecutor:
|
|||
if self._task.loop:
|
||||
if self._task.loop in self._shared_loader_obj.lookup_loader:
|
||||
#TODO: remove convert_bare true and deprecate this in with_
|
||||
if self._task.loop == 'first_found':
|
||||
# first_found loops are special. If the item is undefined
|
||||
# then we want to fall through to the next value rather
|
||||
# than failing.
|
||||
loop_terms = listify_lookup_plugin_terms(terms=self._task.loop_args, templar=templar, loader=self._loader, fail_on_undefined=False, convert_bare=True)
|
||||
loop_terms = [t for t in loop_terms if not templar._contains_vars(t)]
|
||||
else:
|
||||
try:
|
||||
loop_terms = listify_lookup_plugin_terms(terms=self._task.loop_args, templar=templar, loader=self._loader, fail_on_undefined=True, convert_bare=True)
|
||||
except AnsibleUndefinedVariable as e:
|
||||
|
|
Loading…
Add table
Reference in a new issue