From 44877b7c7ea024f4bef96fa2de169edf706a4097 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Mon, 11 Apr 2016 23:19:12 -0400 Subject: [PATCH] Don't use -tt for ssh connections when sudoable=False Due to an apparent race condition while using pty's on a heavily loaded system, rarely a request to create a temp directory returns an empty string rather than the newly created path, causing an error. Disabling forced pty's appears to resolve the issue, so this patch modifies the mkdtemp remote call not use -tt as we're not escalating privileges and thus no pty is required. Fixes #13876 --- lib/ansible/plugins/connection/ssh.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py index dcea2e5f1c..b03b15fc36 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)