From 6693adc9b27e58d5f45498c636feaac1d220b5ca Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Fri, 12 Oct 2018 01:54:09 +0200 Subject: [PATCH] WinRM/PSRP: Add support for unreachable Currently PSRP connection always fail, even if the system is not reachable. This PR fixes this. --- lib/ansible/plugins/connection/psrp.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/ansible/plugins/connection/psrp.py b/lib/ansible/plugins/connection/psrp.py index e6dfcfa1600..dd34e2755f0 100644 --- a/lib/ansible/plugins/connection/psrp.py +++ b/lib/ansible/plugins/connection/psrp.py @@ -166,6 +166,7 @@ from ansible.plugins.connection import ConnectionBase from ansible.plugins.shell.powershell import _common_args from ansible.utils.hashing import secure_hash from ansible.utils.path import makedirs_safe +from requests.exceptions import ConnectTimeout HAS_PYPSRP = True PYPSRP_IMP_ERR = None @@ -243,6 +244,12 @@ class Connection(ConnectionBase): "psrp connection failure during runspace open: %s" % to_native(e) ) + except ConnectTimeout as e: + raise AnsibleConnectionFailure( + "Failed to connect to the host via PSRP: %s" + % to_native(e) + ) + self._connected = True return self