Merge pull request #494 from dhozac/ssh-conn-helpful

Make the SSH transport helpful
pull/603/head
Michael DeHaan 13 years ago
commit dc13265a70

@ -59,7 +59,7 @@ class SSHConnection(object):
def exec_command(self, cmd, tmp_path,sudo_user,sudoable=False): def exec_command(self, cmd, tmp_path,sudo_user,sudoable=False):
''' run a command on the remote host ''' ''' run a command on the remote host '''
ssh_cmd = ["ssh", "-tt"] + self.common_args + [self.userhost] ssh_cmd = ["ssh", "-tt", "-q"] + self.common_args + [self.userhost]
if self.runner.sudo and sudoable: if self.runner.sudo and sudoable:
# Rather than detect if sudo wants a password this time, -k makes # Rather than detect if sudo wants a password this time, -k makes
# sudo always ask for a password if one is required. The "--" # sudo always ask for a password if one is required. The "--"
@ -96,8 +96,20 @@ class SSHConnection(object):
else: else:
ssh_cmd.append(cmd) ssh_cmd.append(cmd)
p = subprocess.Popen(ssh_cmd, stdin=subprocess.PIPE, p = subprocess.Popen(ssh_cmd, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
return (p.stdin, p.stdout, '')
# We can't use p.communicate here because the ControlMaster may have stdout open as well
p.stdin.close()
stdout = ''
while p.poll() is None:
rfd, wfd, efd = select.select([p.stdout], [], [p.stdout], 1)
if p.stdout in rfd:
stdout += os.read(p.stdout.fileno(), 1024)
if p.returncode != 0 and stdout.find('Bad configuration option: ControlPersist') != -1:
raise errors.AnsibleError('using -c ssh on certain older ssh versions may not support ControlPersist, set ANSIBLE_SSH_ARGS="" before running again')
return ('', stdout, '')
def put_file(self, in_path, out_path): def put_file(self, in_path, out_path):
''' transfer a file from local to remote ''' ''' transfer a file from local to remote '''

Loading…
Cancel
Save