diff --git a/lib/ansible/callbacks.py b/lib/ansible/callbacks.py index 65ef94958b..ff35ff054f 100644 --- a/lib/ansible/callbacks.py +++ b/lib/ansible/callbacks.py @@ -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: diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 4cd904e521..78895fe4da 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -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'] != '': diff --git a/lib/ansible/runner/connection_plugins/ssh.py b/lib/ansible/runner/connection_plugins/ssh.py index 649429c3c9..478f85b3d6 100644 --- a/lib/ansible/runner/connection_plugins/ssh.py +++ b/lib/ansible/runner/connection_plugins/ssh.py @@ -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] diff --git a/lib/ansible/utils/__init__.py b/lib/ansible/utils/__init__.py index 18223cdad1..2ba2d2d8fe 100644 --- a/lib/ansible/utils/__init__.py +++ b/lib/ansible/utils/__init__.py @@ -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)