mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
allow skipping tasks due to undefined var
mimic 1.x behaviour but give out big deprecation message, not only for missing attribute but any undefined error.
This commit is contained in:
parent
cd076dbcfa
commit
347b28252a
1 changed files with 5 additions and 11 deletions
|
@ -178,21 +178,15 @@ class TaskExecutor:
|
||||||
# first_found loops are special. If the item is undefined
|
# first_found loops are special. If the item is undefined
|
||||||
# then we want to fall through to the next value rather
|
# then we want to fall through to the next value rather
|
||||||
# than failing.
|
# than failing.
|
||||||
loop_terms = listify_lookup_plugin_terms(terms=self._task.loop_args, templar=templar,
|
loop_terms = listify_lookup_plugin_terms(terms=self._task.loop_args, templar=templar, loader=self._loader, fail_on_undefined=False, convert_bare=True)
|
||||||
loader=self._loader, fail_on_undefined=False, convert_bare=True)
|
|
||||||
loop_terms = [t for t in loop_terms if not templar._contains_vars(t)]
|
loop_terms = [t for t in loop_terms if not templar._contains_vars(t)]
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
loop_terms = listify_lookup_plugin_terms(terms=self._task.loop_args, templar=templar,
|
loop_terms = listify_lookup_plugin_terms(terms=self._task.loop_args, templar=templar, loader=self._loader, fail_on_undefined=True, convert_bare=True)
|
||||||
loader=self._loader, fail_on_undefined=True, convert_bare=True)
|
|
||||||
except AnsibleUndefinedVariable as e:
|
except AnsibleUndefinedVariable as e:
|
||||||
if u'has no attribute' in to_unicode(e):
|
|
||||||
loop_terms = []
|
loop_terms = []
|
||||||
display.deprecated("Skipping task due to undefined attribute, in the future this will be a fatal error.")
|
display.deprecated("Skipping task due to undefined Error, in the future this will be a fatal error.")
|
||||||
else:
|
items = self._shared_loader_obj.lookup_loader.get(self._task.loop, loader=self._loader, templar=templar).run(terms=loop_terms, variables=self._job_vars)
|
||||||
raise
|
|
||||||
items = self._shared_loader_obj.lookup_loader.get(self._task.loop, loader=self._loader,
|
|
||||||
templar=templar).run(terms=loop_terms, variables=self._job_vars)
|
|
||||||
else:
|
else:
|
||||||
raise AnsibleError("Unexpected failure in finding the lookup named '%s' in the available lookup plugins" % self._task.loop)
|
raise AnsibleError("Unexpected failure in finding the lookup named '%s' in the available lookup plugins" % self._task.loop)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue