diff --git a/lib/ansible/module_utils/network/eos/eos.py b/lib/ansible/module_utils/network/eos/eos.py index de873bb6d5f..b7ee53d64fa 100644 --- a/lib/ansible/module_utils/network/eos/eos.py +++ b/lib/ansible/module_utils/network/eos/eos.py @@ -382,7 +382,11 @@ class Eapi: commands = ['configure session %s' % session, 'abort'] self.send_request(commands) err = response['error'] - self._module.fail_json(msg=err['message'], code=err['code']) + error_text = [] + for data in err['data']: + error_text.extend(data.get('errors', [])) + error_text = '\n'.join(error_text) or err['message'] + self._module.fail_json(msg=error_text, code=err['code']) commands = ['configure session %s' % session, 'show session-config diffs'] if commit: diff --git a/lib/ansible/plugins/httpapi/eos.py b/lib/ansible/plugins/httpapi/eos.py index b079351d8f0..db821e88bf0 100644 --- a/lib/ansible/plugins/httpapi/eos.py +++ b/lib/ansible/plugins/httpapi/eos.py @@ -87,7 +87,12 @@ class HttpApi: else: commands.append(command) - response = self.send_request(commands) + try: + response = self.send_request(commands) + except Exception: + commands = ['configure session %s' % session, 'abort'] + response = self.send_request(commands, output='text') + raise commands = ['configure session %s' % session, 'show session-config diffs'] if commit: @@ -153,7 +158,13 @@ class HttpApi: def handle_response(response): if 'error' in response: error = response['error'] - raise ConnectionError(error['message'], code=error['code']) + + error_text = [] + for data in error['data']: + error_text.extend(data.get('errors', [])) + error_text = '\n'.join(error_text) or error['message'] + + raise ConnectionError(error_text, code=error['code']) results = [] for result in response['result']: diff --git a/lib/ansible/plugins/terminal/eos.py b/lib/ansible/plugins/terminal/eos.py index 3eb3c15b031..5f6d48dff89 100644 --- a/lib/ansible/plugins/terminal/eos.py +++ b/lib/ansible/plugins/terminal/eos.py @@ -45,7 +45,8 @@ class TerminalModule(TerminalBase): re.compile(br"[^\r\n]+ not found", re.I), re.compile(br"'[^']' +returned error code: ?\d+"), re.compile(br"[^\r\n]\/bin\/(?:ba)?sh"), - re.compile(br"% More than \d+ OSPF instance", re.I) + re.compile(br"% More than \d+ OSPF instance", re.I), + re.compile(br"% Subnet [0-9a-f.:/]+ overlaps", re.I), ] def on_open_shell(self):