diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 8da794ba6ff..b1652d86e34 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -733,6 +733,10 @@ class Runner(object): result = utils.jsonify(dict(changed=False, skipped=True)) self.callbacks.on_skipped(host, None) return ReturnData(host=host, result=result) + except errors.AnsibleError, e: + raise + except Exception, e: + raise errors.AnsibleError("Unexpected error while executing task: %s" % str(e)) # strip out any jinja2 template syntax within # the data returned by the lookup plugin diff --git a/lib/ansible/utils/template.py b/lib/ansible/utils/template.py index c2b14d8454b..3e7f5e4d811 100644 --- a/lib/ansible/utils/template.py +++ b/lib/ansible/utils/template.py @@ -89,13 +89,12 @@ def lookup(name, *args, **kwargs): tvars = kwargs.get('vars', None) if instance is not None: - # safely catch run failures per #5059 try: ran = instance.run(*args, inject=tvars, **kwargs) - except errors.AnsibleUndefinedVariable: + except errors.AnsibleError: raise except Exception, e: - ran = None + raise errors.AnsibleError('Unexpected error in during lookup: %s' % e) if ran: ran = ",".join(ran) return ran