mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
parent
c063803a91
commit
f4d68b8860
4 changed files with 14 additions and 11 deletions
|
@ -40,6 +40,7 @@ from ansible.errors import AnsibleError, AnsibleOptionsError, AnsibleParserError
|
||||||
from ansible.utils.display import Display
|
from ansible.utils.display import Display
|
||||||
from ansible.utils.unicode import to_unicode
|
from ansible.utils.unicode import to_unicode
|
||||||
|
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
### OUTPUT OF LAST RESORT ###
|
### OUTPUT OF LAST RESORT ###
|
||||||
class LastResort(object):
|
class LastResort(object):
|
||||||
|
@ -108,7 +109,7 @@ if __name__ == '__main__':
|
||||||
have_cli_options = cli is not None and cli.options is not None
|
have_cli_options = cli is not None and cli.options is not None
|
||||||
display.error("Unexpected Exception: %s" % to_unicode(e), wrap_text=False)
|
display.error("Unexpected Exception: %s" % to_unicode(e), wrap_text=False)
|
||||||
if not have_cli_options or have_cli_options and cli.options.verbosity > 2:
|
if not have_cli_options or have_cli_options and cli.options.verbosity > 2:
|
||||||
display.display("the full traceback was:\n\n%s" % traceback.format_exc())
|
display.display(u"the full traceback was:\n\n%s" % to_unicode(traceback.format_exc()))
|
||||||
else:
|
else:
|
||||||
display.display("to see the full traceback, use -vvv")
|
display.display("to see the full traceback, use -vvv")
|
||||||
sys.exit(250)
|
sys.exit(250)
|
||||||
|
|
|
@ -48,6 +48,7 @@ from ansible.playbook.task import Task
|
||||||
from ansible.vars.unsafe_proxy import AnsibleJSONUnsafeDecoder
|
from ansible.vars.unsafe_proxy import AnsibleJSONUnsafeDecoder
|
||||||
|
|
||||||
from ansible.utils.debug import debug
|
from ansible.utils.debug import debug
|
||||||
|
from ansible.utils.unicode import to_unicode
|
||||||
|
|
||||||
__all__ = ['WorkerProcess']
|
__all__ = ['WorkerProcess']
|
||||||
|
|
||||||
|
@ -135,11 +136,11 @@ class WorkerProcess(multiprocessing.Process):
|
||||||
try:
|
try:
|
||||||
self._host.vars = dict()
|
self._host.vars = dict()
|
||||||
self._host.groups = []
|
self._host.groups = []
|
||||||
task_result = TaskResult(self._host, self._task, dict(failed=True, exception=traceback.format_exc(), stdout=''))
|
task_result = TaskResult(self._host, self._task, dict(failed=True, exception=to_unicode(traceback.format_exc()), stdout=''))
|
||||||
self._rslt_q.put(task_result, block=False)
|
self._rslt_q.put(task_result, block=False)
|
||||||
except:
|
except:
|
||||||
debug("WORKER EXCEPTION: %s" % e)
|
debug(u"WORKER EXCEPTION: %s" % to_unicode(e))
|
||||||
debug("WORKER EXCEPTION: %s" % traceback.format_exc())
|
debug(u"WORKER EXCEPTION: %s" % to_unicode(traceback.format_exc()))
|
||||||
|
|
||||||
debug("WORKER PROCESS EXITING")
|
debug("WORKER PROCESS EXITING")
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ from ansible.plugins import callback_loader, strategy_loader, module_loader
|
||||||
from ansible.template import Templar
|
from ansible.template import Templar
|
||||||
from ansible.vars.hostvars import HostVars
|
from ansible.vars.hostvars import HostVars
|
||||||
from ansible.plugins.callback import CallbackBase
|
from ansible.plugins.callback import CallbackBase
|
||||||
|
from ansible.utils.unicode import to_unicode
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from __main__ import display
|
from __main__ import display
|
||||||
|
@ -306,7 +307,7 @@ class TaskQueueManager:
|
||||||
method(*args, **kwargs)
|
method(*args, **kwargs)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
import traceback
|
import traceback
|
||||||
orig_tb = traceback.format_exc()
|
orig_tb = to_unicode(traceback.format_exc())
|
||||||
try:
|
try:
|
||||||
v1_method = method.replace('v2_','')
|
v1_method = method.replace('v2_','')
|
||||||
v1_method(*args, **kwargs)
|
v1_method(*args, **kwargs)
|
||||||
|
|
|
@ -137,20 +137,20 @@ class Connection(ConnectionBase):
|
||||||
protocol.send_message('')
|
protocol.send_message('')
|
||||||
return protocol
|
return protocol
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
err_msg = (str(e) or repr(e)).strip()
|
err_msg = to_unicode(e).strip()
|
||||||
if re.search(r'Operation\s+?timed\s+?out', err_msg, re.I):
|
if re.search(ur'Operation\s+?timed\s+?out', err_msg, re.I):
|
||||||
raise AnsibleError('the connection attempt timed out')
|
raise AnsibleError('the connection attempt timed out')
|
||||||
m = re.search(r'Code\s+?(\d{3})', err_msg)
|
m = re.search(ur'Code\s+?(\d{3})', err_msg)
|
||||||
if m:
|
if m:
|
||||||
code = int(m.groups()[0])
|
code = int(m.groups()[0])
|
||||||
if code == 401:
|
if code == 401:
|
||||||
err_msg = 'the username/password specified for this server was incorrect'
|
err_msg = 'the username/password specified for this server was incorrect'
|
||||||
elif code == 411:
|
elif code == 411:
|
||||||
return protocol
|
return protocol
|
||||||
errors.append('%s: %s' % (transport, err_msg))
|
errors.append(u'%s: %s' % (transport, err_msg))
|
||||||
display.vvvvv('WINRM CONNECTION ERROR: %s\n%s' % (err_msg, traceback.format_exc()), host=self._winrm_host)
|
display.vvvvv(u'WINRM CONNECTION ERROR: %s\n%s' % (err_msg, to_unicode(traceback.format_exc())), host=self._winrm_host)
|
||||||
if errors:
|
if errors:
|
||||||
raise AnsibleError(', '.join(errors))
|
raise AnsibleError(', '.join(to_str(errors)))
|
||||||
else:
|
else:
|
||||||
raise AnsibleError('No transport found for WinRM connection')
|
raise AnsibleError('No transport found for WinRM connection')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue