mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Catch exceptions during module execution so they don't fail the worker
Fixes #14120
This commit is contained in:
parent
5a88478ccc
commit
2adddac94c
1 changed files with 3 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue