diff options
author | Peter Sprygada <psprygada@ansible.com> | 2016-05-04 11:12:26 -0400 |
---|---|---|
committer | Peter Sprygada <psprygada@ansible.com> | 2016-05-18 06:55:17 -0400 |
commit | 309aba128cc7cec93c265f883275f701b14bb1d6 (patch) | |
tree | 76f9dfad4f7f8f88ed01d3a8a6e6962a872a43e6 | |
parent | ff346a199c3e3ca0c54b3e9a656f7105b3e55cb0 (diff) | |
download | ansible-309aba128cc7cec93c265f883275f701b14bb1d6.tar.gz |
handle name resolution errors more gracefully from shell.py
This change will catch socket.gaierror exceptions from shell.py and
return a more friendly message to the user
-rw-r--r-- | lib/ansible/module_utils/shell.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/ansible/module_utils/shell.py b/lib/ansible/module_utils/shell.py index a01b41b0c5..3ee770823e 100644 --- a/lib/ansible/module_utils/shell.py +++ b/lib/ansible/module_utils/shell.py @@ -101,12 +101,15 @@ class Shell(object): if not look_for_keys: look_for_keys = password is None - self.ssh.connect(host, port=port, username=username, password=password, - timeout=timeout, look_for_keys=look_for_keys, pkey=pkey, - key_filename=key_filename, allow_agent=allow_agent) - - self.shell = self.ssh.invoke_shell() - self.shell.settimeout(timeout) + try: + self.ssh.connect(host, port=port, username=username, password=password, + timeout=timeout, look_for_keys=look_for_keys, pkey=pkey, + key_filename=key_filename, allow_agent=allow_agent) + + self.shell = self.ssh.invoke_shell() + self.shell.settimeout(timeout) + except socket.gaierror: + raise ShellError("unable to resolve host name") if self.kickstart: self.shell.sendall("\n") |