diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py index dcea2e5f1c8..b03b15fc360 100644 --- a/lib/ansible/plugins/connection/ssh.py +++ b/lib/ansible/plugins/connection/ssh.py @@ -559,11 +559,12 @@ class Connection(ConnectionBase): # python interactive-mode but the modules are not compatible with the # interactive-mode ("unexpected indent" mainly because of empty lines) - if in_data: - cmd = self._build_command('ssh', self.host, cmd) + if not in_data and sudoable: + args = ('ssh', '-tt', self.host, cmd) else: - cmd = self._build_command('ssh', '-tt', self.host, cmd) + args = ('ssh', self.host, cmd) + cmd = self._build_command(*args) (returncode, stdout, stderr) = self._run(cmd, in_data, sudoable=sudoable) return (returncode, stdout, stderr)