From 820260b22d57aca0ed75fdb81c3b65123788e06d Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Sun, 28 Aug 2016 23:03:46 -0400 Subject: [PATCH] catches timeout error when connecting to remote host in shell This will now catch a timeout error when shell attempts to open the connection to the remove device and gracefully raise it as a ShellError --- lib/ansible/module_utils/shell.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ansible/module_utils/shell.py b/lib/ansible/module_utils/shell.py index ac7b0386868..1094601f402 100644 --- a/lib/ansible/module_utils/shell.py +++ b/lib/ansible/module_utils/shell.py @@ -106,6 +106,11 @@ class Shell(object): raise ShellError("unable to resolve host name") except AuthenticationException: raise ShellError('Unable to authenticate to remote device') + except socket.error: + exc = get_exception() + if exc.errno == 60: + raise ShellError('timeout trying to connect to host') + raise if self.kickstart: self.shell.sendall("\n")