Handle getting the ds for Conditionals which may not be mixed in

pull/11414/head
James Cammarata 9 years ago
parent f433e709f2
commit 9d9cd0c42c

@ -55,14 +55,21 @@ class Conditional:
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:
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=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:
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

Loading…
Cancel
Save