Added option to change ssh executable path (#17377)

pull/17448/head
Andrea Tartaglia 8 years ago committed by Toshio Kuratomi
parent 07e713e7c6
commit dd71469bb7

@ -280,6 +280,7 @@ ANSIBLE_SSH_ARGS = get_config(p, 'ssh_connection', 'ssh_args', 'AN
ANSIBLE_SSH_CONTROL_PATH = get_config(p, 'ssh_connection', 'control_path', 'ANSIBLE_SSH_CONTROL_PATH', "%(directory)s/ansible-ssh-%%h-%%p-%%r") ANSIBLE_SSH_CONTROL_PATH = get_config(p, 'ssh_connection', 'control_path', 'ANSIBLE_SSH_CONTROL_PATH', "%(directory)s/ansible-ssh-%%h-%%p-%%r")
ANSIBLE_SSH_PIPELINING = get_config(p, 'ssh_connection', 'pipelining', 'ANSIBLE_SSH_PIPELINING', False, boolean=True) ANSIBLE_SSH_PIPELINING = get_config(p, 'ssh_connection', 'pipelining', 'ANSIBLE_SSH_PIPELINING', False, boolean=True)
ANSIBLE_SSH_RETRIES = get_config(p, 'ssh_connection', 'retries', 'ANSIBLE_SSH_RETRIES', 0, integer=True) ANSIBLE_SSH_RETRIES = get_config(p, 'ssh_connection', 'retries', 'ANSIBLE_SSH_RETRIES', 0, integer=True)
ANSIBLE_SSH_EXECUTABLE = get_config(p, 'ssh_connection', 'ssh_executable', 'ANSIBLE_SSH_EXECUTABLE', 'ssh')
PARAMIKO_RECORD_HOST_KEYS = get_config(p, 'paramiko_connection', 'record_host_keys', 'ANSIBLE_PARAMIKO_RECORD_HOST_KEYS', True, boolean=True) PARAMIKO_RECORD_HOST_KEYS = get_config(p, 'paramiko_connection', 'record_host_keys', 'ANSIBLE_PARAMIKO_RECORD_HOST_KEYS', True, boolean=True)
PARAMIKO_PROXY_COMMAND = get_config(p, 'paramiko_connection', 'proxy_command', 'ANSIBLE_PARAMIKO_PROXY_COMMAND', None) PARAMIKO_PROXY_COMMAND = get_config(p, 'paramiko_connection', 'proxy_command', 'ANSIBLE_PARAMIKO_PROXY_COMMAND', None)

@ -667,7 +667,8 @@ class TaskExecutor:
else: else:
# see if SSH can support ControlPersist if not use paramiko # see if SSH can support ControlPersist if not use paramiko
try: try:
cmd = subprocess.Popen(['ssh','-o','ControlPersist'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) ssh_executable = C.ANSIBLE_SSH_EXECUTABLE
cmd = subprocess.Popen([ssh_executable, '-o', 'ControlPersist'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(out, err) = cmd.communicate() (out, err) = cmd.communicate()
err = to_text(err) err = to_text(err)
if u"Bad configuration option" in err or u"Usage:" in err: if u"Bad configuration option" in err or u"Usage:" in err:

@ -144,7 +144,7 @@ class Connection(ConnectionBase):
if self._play_context.verbosity > 3: if self._play_context.verbosity > 3:
self._command += ['-vvv'] self._command += ['-vvv']
elif binary == 'ssh': elif binary == C.ANSIBLE_SSH_EXECUTABLE:
# Older versions of ssh (e.g. in RHEL 6) don't accept sftp -q. # Older versions of ssh (e.g. in RHEL 6) don't accept sftp -q.
self._command += ['-q'] self._command += ['-q']
@ -568,10 +568,12 @@ class Connection(ConnectionBase):
# python interactive-mode but the modules are not compatible with the # python interactive-mode but the modules are not compatible with the
# interactive-mode ("unexpected indent" mainly because of empty lines) # interactive-mode ("unexpected indent" mainly because of empty lines)
ssh_executable = C.ANSIBLE_SSH_EXECUTABLE
if not in_data and sudoable: if not in_data and sudoable:
args = ('ssh', '-tt', self.host, cmd) args = (ssh_executable, '-tt', self.host, cmd)
else: else:
args = ('ssh', self.host, cmd) args = (ssh_executable, self.host, cmd)
cmd = self._build_command(*args) cmd = self._build_command(*args)
(returncode, stdout, stderr) = self._run(cmd, in_data, sudoable=sudoable) (returncode, stdout, stderr) = self._run(cmd, in_data, sudoable=sudoable)
@ -682,7 +684,8 @@ class Connection(ConnectionBase):
# TODO: reenable once winrm issues are fixed # TODO: reenable once winrm issues are fixed
# temporarily disabled as we are forced to currently close connections after every task because of winrm # temporarily disabled as we are forced to currently close connections after every task because of winrm
# if self._connected and self._persistent: # if self._connected and self._persistent:
# cmd = self._build_command('ssh', '-O', 'stop', self.host) # ssh_executable = C.ANSIBLE_SSH_EXECUTABLE
# cmd = self._build_command(ssh_executable, '-O', 'stop', self.host)
# #
# cmd = map(to_bytes, cmd) # cmd = map(to_bytes, cmd)
# p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

Loading…
Cancel
Save