From 1da69309e5964f8e9f409076772c6f5c85e841bc Mon Sep 17 00:00:00 2001 From: Till Maas Date: Thu, 30 Jan 2014 14:54:03 +0100 Subject: [PATCH] ssh connection plugin: Report missing sudo password If no password is provided, sudo hangs at the prompt. Identify this and report that the password is missing as an error. --- lib/ansible/runner/connection_plugins/ssh.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/ansible/runner/connection_plugins/ssh.py b/lib/ansible/runner/connection_plugins/ssh.py index 876f206384..136ab31aa0 100644 --- a/lib/ansible/runner/connection_plugins/ssh.py +++ b/lib/ansible/runner/connection_plugins/ssh.py @@ -155,11 +155,16 @@ class Connection(object): rfd, wfd, efd = select.select(rpipes, [], rpipes, 1) # fail early if the sudo/su password is wrong - if self.runner.sudo and sudoable and self.runner.sudo_pass: - incorrect_password = gettext.dgettext( - "sudo", "Sorry, try again.") - if stdout.endswith("%s\r\n%s" % (incorrect_password, prompt)): - raise errors.AnsibleError('Incorrect sudo password') + if self.runner.sudo and sudoable: + if self.runner.sudo_pass: + incorrect_password = gettext.dgettext( + "sudo", "Sorry, try again.") + if stdout.endswith("%s\r\n%s" % (incorrect_password, + prompt)): + raise errors.AnsibleError('Incorrect sudo password') + + if stdout.endswith(prompt): + raise errors.AnsibleError('Missing sudo password') if self.runner.su and su and self.runner.sudo_pass: incorrect_password = gettext.dgettext(