From 955ef020ef9c726fd156734f1c47b4bc38189b88 Mon Sep 17 00:00:00 2001 From: Ganesh Nalawade Date: Thu, 12 Apr 2018 10:43:02 +0530 Subject: [PATCH] Add troubleshooting URL for persistent socket path related issue (#38542) (#38577) * Add troubleshooting URL for persistent socket path related issue socket path timeout related error messages are not displayed on the console as the ansible-connection process does not have access to it. Until this is fixed need to point to troubleshooting URL so that users can take corrective actions. * Fix CI issue * Update changelog fragments (cherry picked from commit 53d3e7e306770d403841ee0215c91aa9e3999885) --- .../fragments/persistent_socket_path_troubleshoot_url.yml | 2 ++ lib/ansible/module_utils/connection.py | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/persistent_socket_path_troubleshoot_url.yml diff --git a/changelogs/fragments/persistent_socket_path_troubleshoot_url.yml b/changelogs/fragments/persistent_socket_path_troubleshoot_url.yml new file mode 100644 index 00000000000..a7db7047779 --- /dev/null +++ b/changelogs/fragments/persistent_socket_path_troubleshoot_url.yml @@ -0,0 +1,2 @@ +bugfixes: +- Add url to troubleshoot persistent socket path related issues https://github.com/ansible/ansible/pull/38542 diff --git a/lib/ansible/module_utils/connection.py b/lib/ansible/module_utils/connection.py index 28cc4645fb6..7e1aceba905 100644 --- a/lib/ansible/module_utils/connection.py +++ b/lib/ansible/module_utils/connection.py @@ -111,8 +111,10 @@ class Connection(object): req = request_builder(name, *args, **kwargs) reqid = req['id'] + troubleshoot = 'http://docs.ansible.com/ansible/latest/network/user_guide/network_debug_troubleshooting.html#category-socket-path-issue' + if not os.path.exists(self.socket_path): - raise ConnectionError('socket_path does not exist or cannot be found') + raise ConnectionError('socket_path does not exist or cannot be found. Please check %s' % troubleshoot) try: data = json.dumps(req) @@ -120,7 +122,8 @@ class Connection(object): response = json.loads(out) except socket.error as e: - raise ConnectionError('unable to connect to socket', err=to_text(e, errors='surrogate_then_replace'), exception=traceback.format_exc()) + raise ConnectionError('unable to connect to socket. Please check %s' % troubleshoot, err=to_text(e, errors='surrogate_then_replace'), + exception=traceback.format_exc()) if response['id'] != reqid: raise ConnectionError('invalid json-rpc id received')