diff --git a/lib/ansible/runner/connection_plugins/paramiko_ssh.py b/lib/ansible/runner/connection_plugins/paramiko_ssh.py index f3e293c8fe9..6700efa8c73 100644 --- a/lib/ansible/runner/connection_plugins/paramiko_ssh.py +++ b/lib/ansible/runner/connection_plugins/paramiko_ssh.py @@ -119,7 +119,12 @@ class Connection(object): vvv("EXEC %s" % quoted_command, host=self.host) chan.exec_command(quoted_command) else: - chan.get_pty() + # sudo usually requires a PTY (cf. requiretty option), therefore + # we give it one, and we try to initialise from the calling + # environment + chan.get_pty(term=os.getenv('TERM', 'vt100'), + width=os.getenv('COLUMNS', 0), + height=os.getenv('LINES', 0)) shcmd, prompt = utils.make_sudo_cmd(sudo_user, executable, cmd) vvv("EXEC %s" % shcmd, host=self.host) sudo_output = ''