Catch auth errors in winrm and properly raise errors

Fixes #7875
release1.7.1
James Cammarata 10 years ago
parent 1dd484cc2d
commit a77674145f

@ -89,17 +89,19 @@ class Connection(object):
except WinRMTransportError, exc: except WinRMTransportError, exc:
err_msg = str(exc.args[0]) err_msg = str(exc.args[0])
if re.search(r'Operation\s+?timed\s+?out', err_msg, re.I): 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) m = re.search(r'Code\s+?(\d{3})', err_msg)
if m: if m:
code = int(m.groups()[0]) 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 _winrm_cache[cache_key] = protocol
return protocol return protocol
vvvv('WINRM CONNECTION ERROR: %s' % err_msg, host=self.host) vvvv('WINRM CONNECTION ERROR: %s' % err_msg, host=self.host)
continue continue
if exc: if exc:
raise exc raise errors.AnsibleError(str(exc))
def _winrm_exec(self, command, args=(), from_exec=False): def _winrm_exec(self, command, args=(), from_exec=False):
if from_exec: if from_exec:

Loading…
Cancel
Save