Commit 8ef28253 by James Cammarata

Properly catch and report conditional test failures

parent 0eb1c880
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
from jinja2.exceptions import UndefinedError
from ansible.errors import * from ansible.errors import *
from ansible.playbook.attribute import FieldAttribute from ansible.playbook.attribute import FieldAttribute
from ansible.template import Templar from ansible.template import Templar
...@@ -53,9 +55,14 @@ class Conditional: ...@@ -53,9 +55,14 @@ class Conditional:
False if any of them evaluate as such. False if any of them evaluate as such.
''' '''
for conditional in self.when: try:
if not self._check_conditional(conditional, templar, all_vars): for conditional in self.when:
return False 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())
except Exception, e:
raise AnsibleError("The conditional check '%s' failed. The error was: %s" % (conditional, e), obj=self.get_ds())
return True return True
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment