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*)$') ]