minor fixes to ssh error reporting

shoudl fix #11041
This commit is contained in:
Brian Coca 2015-06-06 00:16:35 -04:00
parent 1a0775a498
commit bdba807fd1
2 changed files with 27 additions and 17 deletions

View file

@ -161,12 +161,12 @@ class ActionBase:
if result['rc'] == 5:
output = 'Authentication failure.'
elif result['rc'] == 255 and self._connection.transport in ('ssh',):
# FIXME: more utils.VERBOSITY
#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'
output = 'SSH encountered an unknown error. The output was:\n%s' % (result['stdout']+result['stderr'])
if self._connection_info.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'
elif 'No space left on device' in result['stderr']:
output = result['stderr']
else:
@ -462,7 +462,7 @@ class ActionBase:
err = stderr
debug("done with _low_level_execute_command() (%s)" % (cmd,))
if rc is not None:
return dict(rc=rc, stdout=out, stderr=err)
else:
return dict(stdout=out, stderr=err)
if rc is None:
rc = 0
return dict(rc=rc, stdout=out, stderr=err)

View file

@ -398,14 +398,14 @@ class Connection(ConnectionBase):
super(Connection, self).put_file(in_path, out_path)
self._display.vvv("PUT {0} TO {1}".format(in_path, out_path), host=self._connection_info.remote_addr)
# FIXME: make a function, used in all 3 methods EXEC/PUT/FETCH
host = self._connection_info.remote_addr
self._display.vvv("PUT {0} TO {1}".format(in_path, out_path), host=host)
if not os.path.exists(in_path):
raise AnsibleFileNotFound("file or module does not exist: {0}".format(in_path))
cmd = self._password_cmd()
# FIXME: make a function, used in all 3 methods EXEC/PUT/FETCH
host = self._connection_info.remote_addr
# FIXME: ipv6 stuff needs to be figured out. It's in the connection info, however
# not sure if it's all working yet so this remains commented out
#if self._ipv6:
@ -436,12 +436,13 @@ class Connection(ConnectionBase):
super(Connection, self).fetch_file(in_path, out_path)
self._display.vvv("FETCH {0} TO {1}".format(in_path, out_path), host=self._connection_info.remote_addr)
cmd = self._password_cmd()
# FIXME: make a function, used in all 3 methods EXEC/PUT/FETCH
host = self._connection_info.remote_addr
self._display.vvv("FETCH {0} TO {1}".format(in_path, out_path), host=host)
cmd = self._password_cmd()
# FIXME: ipv6 stuff needs to be figured out. It's in the connection info, however
# not sure if it's all working yet so this remains commented out
#if self._ipv6:
@ -467,5 +468,14 @@ class Connection(ConnectionBase):
def close(self):
''' not applicable since we're executing openssh binaries '''
if 'ControlMaster' in self._common_args:
cmd = ['ssh','-O','stop']
cmd.extend(self._common_args)
cmd.append(self._connection_info.remote_addr)
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
self._connected = False