mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Handle getting the ds for Conditionals which may not be mixed in
This commit is contained in:
parent
f433e709f2
commit
9d9cd0c42c
1 changed files with 9 additions and 2 deletions
|
@ -55,14 +55,21 @@ class Conditional:
|
||||||
False if any of them evaluate as such.
|
False if any of them evaluate as such.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
# since this is a mixin, it may not have an underlying datastructure
|
||||||
|
# associated with it, so we pull it out now in case we need it for
|
||||||
|
# error reporting below
|
||||||
|
ds = None
|
||||||
|
if hasattr(self, 'get_ds'):
|
||||||
|
ds = self.get_ds()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for conditional in self.when:
|
for conditional in self.when:
|
||||||
if not self._check_conditional(conditional, templar, all_vars):
|
if not self._check_conditional(conditional, templar, all_vars):
|
||||||
return False
|
return False
|
||||||
except UndefinedError, e:
|
except UndefinedError, e:
|
||||||
raise AnsibleError("The conditional check '%s' failed due to an undefined variable. The error was: %s" % (conditional, e), obj=self.get_ds())
|
raise AnsibleError("The conditional check '%s' failed due to an undefined variable. The error was: %s" % (conditional, e), obj=ds)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
raise AnsibleError("The conditional check '%s' failed. The error was: %s" % (conditional, e), obj=self.get_ds())
|
raise AnsibleError("The conditional check '%s' failed. The error was: %s" % (conditional, e), obj=ds)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue