From db7c82ea21273d3b5ea0910b7e792aa2bbb30805 Mon Sep 17 00:00:00 2001 From: Albert Siersema Date: Tue, 16 Jul 2019 23:03:45 +0200 Subject: [PATCH] Backport/2.8/55218 (#58639) * "no macro" command should not be handled by edit_macro(), fixes #55212 (cherry picked from commit 2cdab1379f4b51f0313734e27ea77af81afee90a) * fixed ios_config issue where the "no macro" command was erroneously handled by edit_macro() --- .../ios_command_edit_macro_dont_handle_no_macro.yaml | 2 ++ lib/ansible/modules/network/ios/ios_config.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/ios_command_edit_macro_dont_handle_no_macro.yaml diff --git a/changelogs/fragments/ios_command_edit_macro_dont_handle_no_macro.yaml b/changelogs/fragments/ios_command_edit_macro_dont_handle_no_macro.yaml new file mode 100644 index 00000000000..cb3f5c75bbc --- /dev/null +++ b/changelogs/fragments/ios_command_edit_macro_dont_handle_no_macro.yaml @@ -0,0 +1,2 @@ +bugfixes: + - ios_config - fixed issue where the "no macro" command was erroneously handled by edit_macro(). https://github.com/ansible/ansible/issues/55212 diff --git a/lib/ansible/modules/network/ios/ios_config.py b/lib/ansible/modules/network/ios/ios_config.py index 28bb5fc9325..0a66a1ef194 100644 --- a/lib/ansible/modules/network/ios/ios_config.py +++ b/lib/ansible/modules/network/ios/ios_config.py @@ -356,7 +356,9 @@ def check_args(module, warnings): def edit_config_or_macro(connection, commands): - if "macro name" in commands[0]: + # only catch the macro configuration command, + # not negated 'no' variation. + if commands[0].startswith("macro name"): connection.edit_macro(candidate=commands) else: connection.edit_config(candidate=commands)