Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the SSH transport helpful #494

Merged
merged 3 commits into from
Jun 20, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 15 additions & 3 deletions lib/ansible/runner/connection/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def connect(self):
def exec_command(self, cmd, tmp_path,sudo_user,sudoable=False):
''' 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:
# Rather than detect if sudo wants a password this time, -k makes
# sudo always ask for a password if one is required. The "--"
Expand Down Expand Up @@ -96,8 +96,20 @@ def exec_command(self, cmd, tmp_path,sudo_user,sudoable=False):
else:
ssh_cmd.append(cmd)
p = subprocess.Popen(ssh_cmd, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return (p.stdin, p.stdout, '')
stdout=subprocess.PIPE, stderr=subprocess.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):
''' transfer a file from local to remote '''
Expand Down