mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Added support for -vvvv to enable ssh connection debugging
This patch also checks specifically for a return code of 255, which indicates an unknown SSH error of some kind. When that happens, ansible will now recommend running with -vvvv (if not enabled) or show the output from 'ssh -vvv' (when it is enabled)
This commit is contained in:
parent
503f062521
commit
d5b96abd80
4 changed files with 16 additions and 2 deletions
|
@ -158,6 +158,9 @@ def vv(msg, host=None):
|
|||
def vvv(msg, host=None):
|
||||
return verbose(msg, host=host, caplevel=2)
|
||||
|
||||
def vvvv(msg, host=None):
|
||||
return verbose(msg, host=host, caplevel=3)
|
||||
|
||||
def verbose(msg, host=None, caplevel=2):
|
||||
if utils.VERBOSITY > caplevel:
|
||||
if host is None:
|
||||
|
|
|
@ -776,6 +776,11 @@ class Runner(object):
|
|||
if result['rc'] != 0:
|
||||
if result['rc'] == 5:
|
||||
output = 'Authentication failure.'
|
||||
elif result['rc'] == 255:
|
||||
if utils.VERBOSITY > 3:
|
||||
output = 'SSH encountered an unknown error. The output was:\n%s' % (result['stdout']+result['stderr'])
|
||||
else:
|
||||
output = 'SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue'
|
||||
else:
|
||||
output = 'Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the remote directory. Consider changing the remote temp path in ansible.cfg to a path rooted in "/tmp". Failed command was: %s, exited with result %d' % (cmd, result['rc'])
|
||||
if 'stdout' in result and result['stdout'] != '':
|
||||
|
|
|
@ -147,7 +147,13 @@ class Connection(object):
|
|||
''' run a command on the remote host '''
|
||||
|
||||
ssh_cmd = self._password_cmd()
|
||||
ssh_cmd += ["ssh", "-tt", "-q"] + self.common_args
|
||||
ssh_cmd += ["ssh", "-tt"]
|
||||
if utils.VERBOSITY > 3:
|
||||
ssh_cmd += ["-vvv"]
|
||||
else:
|
||||
ssh_cmd += ["-q"]
|
||||
ssh_cmd += self.common_args
|
||||
|
||||
if self.ipv6:
|
||||
ssh_cmd += ['-6']
|
||||
ssh_cmd += [self.host]
|
||||
|
|
|
@ -509,7 +509,7 @@ def base_parser(constants=C, usage="", output_opts=False, runas_opts=False,
|
|||
|
||||
parser = SortedOptParser(usage, version=version("%prog"))
|
||||
parser.add_option('-v','--verbose', default=False, action="callback",
|
||||
callback=increment_debug, help="verbose mode (-vvv for more)")
|
||||
callback=increment_debug, help="verbose mode (-vvv for more, -vvvv to enable connection debugging)")
|
||||
|
||||
parser.add_option('-f','--forks', dest='forks', default=constants.DEFAULT_FORKS, type='int',
|
||||
help="specify number of parallel processes to use (default=%s)" % constants.DEFAULT_FORKS)
|
||||
|
|
Loading…
Reference in a new issue