diff options
author | Andrea Tartaglia <me@andreatartaglia.com> | 2016-09-07 22:13:11 +0100 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2016-09-07 14:13:11 -0700 |
commit | ba28f1a2dab6e9f067c360c151e6bb0c37d94f8e (patch) | |
tree | b26a8ebcac17f8a68cb97bbdac50c78bc0518550 | |
parent | d1a7e07ccc368113d90da677d66e48e5aff21e56 (diff) | |
download | ansible-ba28f1a2dab6e9f067c360c151e6bb0c37d94f8e.tar.gz |
Make ssh_executable available as ansible_ssh_* variable (#17450)
-rw-r--r-- | lib/ansible/playbook/play_context.py | 3 | ||||
-rw-r--r-- | lib/ansible/plugins/connection/ssh.py | 7 |
2 files changed, 7 insertions, 3 deletions
diff --git a/lib/ansible/playbook/play_context.py b/lib/ansible/playbook/play_context.py index b03d47d371..716e7c1932 100644 --- a/lib/ansible/playbook/play_context.py +++ b/lib/ansible/playbook/play_context.py @@ -53,6 +53,7 @@ MAGIC_VARIABLE_MAPPING = dict( remote_addr = ('ansible_ssh_host', 'ansible_host'), remote_user = ('ansible_ssh_user', 'ansible_user'), port = ('ansible_ssh_port', 'ansible_port'), + ssh_executable = ('ansible_ssh_executable',), accelerate_port = ('ansible_accelerate_port',), password = ('ansible_ssh_pass', 'ansible_password'), private_key_file = ('ansible_ssh_private_key_file', 'ansible_private_key_file'), @@ -139,6 +140,7 @@ RESET_VARS = ( 'ansible_ssh_user', 'ansible_ssh_private_key_file', 'ansible_ssh_pipelining', + 'ansible_ssh_executable', 'ansible_user', 'ansible_host', 'ansible_port', @@ -165,6 +167,7 @@ class PlayContext(Base): _sftp_extra_args = FieldAttribute(isa='string') _scp_extra_args = FieldAttribute(isa='string') _ssh_extra_args = FieldAttribute(isa='string') + _ssh_executable = FieldAttribute(isa='string', default=C.ANSIBLE_SSH_EXECUTABLE) _connection_lockfd= FieldAttribute(isa='int') _pipelining = FieldAttribute(isa='bool', default=C.ANSIBLE_SSH_PIPELINING) _accelerate = FieldAttribute(isa='bool', default=False) diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py index ac34e8fc88..c24752e182 100644 --- a/lib/ansible/plugins/connection/ssh.py +++ b/lib/ansible/plugins/connection/ssh.py @@ -144,7 +144,7 @@ class Connection(ConnectionBase): if self._play_context.verbosity > 3: self._command += ['-vvv'] - elif binary == C.ANSIBLE_SSH_EXECUTABLE: + elif binary == self._play_context.ssh_executable: # Older versions of ssh (e.g. in RHEL 6) don't accept sftp -q. self._command += ['-q'] @@ -563,12 +563,13 @@ class Connection(ConnectionBase): display.vvv(u"ESTABLISH SSH CONNECTION FOR USER: {0}".format(self._play_context.remote_user), host=self._play_context.remote_addr) + # we can only use tty when we are not pipelining the modules. piping # data into /usr/bin/python inside a tty automatically invokes the # python interactive-mode but the modules are not compatible with the # interactive-mode ("unexpected indent" mainly because of empty lines) - ssh_executable = C.ANSIBLE_SSH_EXECUTABLE + ssh_executable = self._play_context.ssh_executable if not in_data and sudoable: args = (ssh_executable, '-tt', self.host, cmd) @@ -684,7 +685,7 @@ class Connection(ConnectionBase): # TODO: reenable once winrm issues are fixed # temporarily disabled as we are forced to currently close connections after every task because of winrm # if self._connected and self._persistent: - # ssh_executable = C.ANSIBLE_SSH_EXECUTABLE + # ssh_executable = self._play_context.ssh_executable # cmd = self._build_command(ssh_executable, '-O', 'stop', self.host) # # cmd = map(to_bytes, cmd) |