mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Disable undefined error failures during conditional templating
This allows us to properly catch the 'is defined' and 'is undefined' checks and return the correct boolean result. Fixes #11892
This commit is contained in:
parent
e0b074000e
commit
829a88b906
1 changed files with 1 additions and 3 deletions
|
@ -66,8 +66,6 @@ class Conditional:
|
|||
for conditional in self.when:
|
||||
if not self._check_conditional(conditional, templar, all_vars):
|
||||
return False
|
||||
except UndefinedError, e:
|
||||
raise AnsibleError("The conditional check '%s' failed due to an undefined variable. The error was: %s" % (conditional, e), obj=ds)
|
||||
except Exception, e:
|
||||
raise AnsibleError("The conditional check '%s' failed. The error was: %s" % (conditional, e), obj=ds)
|
||||
|
||||
|
@ -96,7 +94,7 @@ class Conditional:
|
|||
|
||||
# a Jinja2 evaluation that results in something Python can eval!
|
||||
presented = "{%% if %s %%} True {%% else %%} False {%% endif %%}" % conditional
|
||||
conditional = templar.template(presented)
|
||||
conditional = templar.template(presented, fail_on_undefined=False)
|
||||
|
||||
val = conditional.strip()
|
||||
if val == presented:
|
||||
|
|
Loading…
Reference in a new issue