From 89bc43cab04b3c099d44c29b774372ace6cd262f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 8 Aug 2013 17:02:52 +0200 Subject: [PATCH] support i18n on sudo failure --- lib/ansible/runner/connection_plugins/ssh.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/ansible/runner/connection_plugins/ssh.py b/lib/ansible/runner/connection_plugins/ssh.py index a27b8de51c..abbffcf785 100644 --- a/lib/ansible/runner/connection_plugins/ssh.py +++ b/lib/ansible/runner/connection_plugins/ssh.py @@ -25,6 +25,7 @@ import select import fcntl import hmac import pwd +import gettext from hashlib import sha1 import ansible.constants as C from ansible.callbacks import vvv @@ -191,9 +192,11 @@ class Connection(object): rfd, wfd, efd = select.select([p.stdout, p.stderr], [], [p.stdout, p.stderr], 1) # fail early if the sudo password is wrong - if (self.runner.sudo and sudoable and self.runner.sudo_pass and - stdout.endswith("Sorry, try again.\r\n%s" % prompt)): - raise errors.AnsibleError('Incorrect sudo password') + 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 p.stdout in rfd: dat = os.read(p.stdout.fileno(), 9000)