Avoid a traceback when turning an exception into a message
This commit is contained in:
parent
4956a33130
commit
f80494e434
1 changed files with 2 additions and 1 deletions
|
@ -49,6 +49,7 @@ from ansible.module_common import ModuleReplacer
|
||||||
from ansible.module_utils.splitter import split_args, unquote
|
from ansible.module_utils.splitter import split_args, unquote
|
||||||
from ansible.cache import FactCache
|
from ansible.cache import FactCache
|
||||||
from ansible.utils import update_hash
|
from ansible.utils import update_hash
|
||||||
|
from ansible.utils.unicode import to_bytes
|
||||||
|
|
||||||
module_replacer = ModuleReplacer(strip_comments=False)
|
module_replacer = ModuleReplacer(strip_comments=False)
|
||||||
|
|
||||||
|
@ -590,7 +591,7 @@ class Runner(object):
|
||||||
self.callbacks.on_unreachable(host, exec_rc.result)
|
self.callbacks.on_unreachable(host, exec_rc.result)
|
||||||
return exec_rc
|
return exec_rc
|
||||||
except errors.AnsibleError, ae:
|
except errors.AnsibleError, ae:
|
||||||
msg = str(ae)
|
msg = to_bytes(ae)
|
||||||
self.callbacks.on_unreachable(host, msg)
|
self.callbacks.on_unreachable(host, msg)
|
||||||
return ReturnData(host=host, comm_ok=False, result=dict(failed=True, msg=msg))
|
return ReturnData(host=host, comm_ok=False, result=dict(failed=True, msg=msg))
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
Loading…
Reference in a new issue