From 9d9cd0c42ca9a401f299f8cb805aafe3c0817b9e Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Sun, 28 Jun 2015 00:30:27 -0400 Subject: [PATCH] Handle getting the ds for Conditionals which may not be mixed in --- lib/ansible/playbook/conditional.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/ansible/playbook/conditional.py b/lib/ansible/playbook/conditional.py index 0cc0719515..ae7a5f0ba4 100644 --- a/lib/ansible/playbook/conditional.py +++ b/lib/ansible/playbook/conditional.py @@ -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