From 5ebd5c548c4aae3b54feb2de99dc771e91f2f7c2 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Wed, 10 Feb 2016 09:22:57 -0500 Subject: [PATCH] Catch exceptions during module execution so they don't fail the worker Fixes #14120 --- lib/ansible/executor/task_executor.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py index c66d178382a..c9abeb35ef1 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -24,6 +24,7 @@ import json import subprocess import sys import time +import traceback from ansible.compat.six import iteritems, string_types @@ -140,6 +141,8 @@ class TaskExecutor: return res except AnsibleError as e: return dict(failed=True, msg=to_unicode(e, nonstring='simplerepr')) + except Exception as e: + return dict(failed=True, msg='Unexpected failure during module execution.', exception=to_unicode(traceback.format_exc()), stdout='') finally: try: self._connection.close()