From 4a157a72a0f75b3d07646c62abbbcb306e5cf31f Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Wed, 6 Aug 2014 12:10:07 -0500 Subject: [PATCH] Catch auth errors in winrm and properly raise errors Fixes #7875 --- lib/ansible/runner/connection_plugins/winrm.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ansible/runner/connection_plugins/winrm.py b/lib/ansible/runner/connection_plugins/winrm.py index e9ee8692f60..9d7eac42652 100644 --- a/lib/ansible/runner/connection_plugins/winrm.py +++ b/lib/ansible/runner/connection_plugins/winrm.py @@ -89,17 +89,19 @@ class Connection(object): except WinRMTransportError, exc: err_msg = str(exc.args[0]) if re.search(r'Operation\s+?timed\s+?out', err_msg, re.I): - raise + raise errors.AnsibleError("the connection attempt timed out") m = re.search(r'Code\s+?(\d{3})', err_msg) if m: code = int(m.groups()[0]) - if code == 411: + if code == 401: + raise errors.AnsibleError("the username/password specified for this server was incorrect") + elif code == 411: _winrm_cache[cache_key] = protocol return protocol vvvv('WINRM CONNECTION ERROR: %s' % err_msg, host=self.host) continue if exc: - raise exc + raise errors.AnsibleError(str(exc)) def _winrm_exec(self, command, args=(), from_exec=False): if from_exec: