From ebc36eed8ca3df1b642d9949b908e0347a183a04 Mon Sep 17 00:00:00 2001 From: Trishna Guha Date: Thu, 7 Jun 2018 22:15:30 +0530 Subject: [PATCH] fix nxos output truncated issue and nxos_banner issue (#40962) * fix nxos output truncated issue Signed-off-by: Trishna Guha * add changelog Signed-off-by: Trishna Guha * fix nxos_banner issue (#41026) (cherry picked from commit b6afb77a8af69fff4f99897e87151cebd6fa40d3) * add changelog for nxos_banner fix Signed-off-by: Trishna Guha --- changelogs/fragments/nxos_banner_2.5.5.yaml | 2 ++ .../fragments/nxos_bugfix_terminal_plugin_2.5.5.yaml | 2 ++ lib/ansible/modules/network/nxos/nxos_banner.py | 12 +++++++++++- lib/ansible/plugins/terminal/nxos.py | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/nxos_banner_2.5.5.yaml create mode 100644 changelogs/fragments/nxos_bugfix_terminal_plugin_2.5.5.yaml diff --git a/changelogs/fragments/nxos_banner_2.5.5.yaml b/changelogs/fragments/nxos_banner_2.5.5.yaml new file mode 100644 index 00000000000..730a0130f2f --- /dev/null +++ b/changelogs/fragments/nxos_banner_2.5.5.yaml @@ -0,0 +1,2 @@ +bugfixes: +- Fix nxos_banner issue (https://github.com/ansible/ansible/pull/41026). diff --git a/changelogs/fragments/nxos_bugfix_terminal_plugin_2.5.5.yaml b/changelogs/fragments/nxos_bugfix_terminal_plugin_2.5.5.yaml new file mode 100644 index 00000000000..19afdb41050 --- /dev/null +++ b/changelogs/fragments/nxos_bugfix_terminal_plugin_2.5.5.yaml @@ -0,0 +1,2 @@ +bugfixes: +- Fix nxos output truncate for upgrade (https://github.com/ansible/ansible/pull/40960). diff --git a/lib/ansible/modules/network/nxos/nxos_banner.py b/lib/ansible/modules/network/nxos/nxos_banner.py index ae4a7b04e8f..ea854610faf 100644 --- a/lib/ansible/modules/network/nxos/nxos_banner.py +++ b/lib/ansible/modules/network/nxos/nxos_banner.py @@ -199,7 +199,17 @@ def main(): if commands: if not module.check_mode: - load_config(module, commands) + msgs = load_config(module, commands, True) + if msgs: + for item in msgs: + if item: + if isinstance(item, dict): + err_str = item['clierror'] + else: + err_str = item + if 'more than 40 lines' in err_str or 'buffer overflowed' in err_str: + load_config(module, commands) + result['changed'] = True module.exit_json(**result) diff --git a/lib/ansible/plugins/terminal/nxos.py b/lib/ansible/plugins/terminal/nxos.py index 31fb556be0b..a7edf1e01bf 100644 --- a/lib/ansible/plugins/terminal/nxos.py +++ b/lib/ansible/plugins/terminal/nxos.py @@ -30,7 +30,7 @@ from ansible.module_utils._text import to_bytes, to_text class TerminalModule(TerminalBase): terminal_stdout_re = [ - re.compile(br'[\r\n]?(?!\s*<)?(\x1b\S+)*[a-zA-Z_0-9]{1}[a-zA-Z0-9-_.]*[>|#|%](?:\s*)*(\x1b\S+)*$'), + re.compile(br'[\r\n]?(?!\s*<)?(\x1b\S+)*[a-zA-Z_0-9]{1}[a-zA-Z0-9-_.]*[>|#](?:\s*)*(\x1b\S+)*$'), re.compile(br'[\r\n]?[a-zA-Z0-9]{1}[a-zA-Z0-9-_.]*\(.+\)#(?:\s*)$') ]