From 14b5b4db01145aab9bc58a5944b6a6e00506ae95 Mon Sep 17 00:00:00 2001 From: Nathan Beard Date: Tue, 11 Mar 2025 15:49:00 -0500 Subject: [PATCH 1/4] Update the banner module to allow exec banner configuration on IOS-XR --- plugins/modules/iosxr_banner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/iosxr_banner.py b/plugins/modules/iosxr_banner.py index 909d79511..85f947fe9 100644 --- a/plugins/modules/iosxr_banner.py +++ b/plugins/modules/iosxr_banner.py @@ -255,7 +255,7 @@ def run(self): def main(): """main entry point for module execution""" argument_spec = dict( - banner=dict(required=True, choices=["login", "motd"]), + banner=dict(required=True, choices=["login", "motd", "exec"]), text=dict(), state=dict(default="present", choices=["present", "absent"]), ) From 0341c90b6a4ced0207c499f0eba66f0acfd1e195 Mon Sep 17 00:00:00 2001 From: Nathan Beard Date: Wed, 12 Mar 2025 08:33:20 -0500 Subject: [PATCH 2/4] Documenation update to reference 'exec' banner --- docs/cisco.iosxr.iosxr_banner_module.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/cisco.iosxr.iosxr_banner_module.rst b/docs/cisco.iosxr.iosxr_banner_module.rst index 46d105682..85ac6dca7 100644 --- a/docs/cisco.iosxr.iosxr_banner_module.rst +++ b/docs/cisco.iosxr.iosxr_banner_module.rst @@ -17,7 +17,7 @@ Version added: 1.0.0 Synopsis -------- -- This module will configure both exec and motd banners on remote device running Cisco IOS XR. It allows playbooks to add or remove banner text from the running configuration. +- This module will configure both login, motd, and exec banners on remote devices running Cisco IOS XR. It allows playbooks to add or remove banner text from the running configuration. @@ -54,6 +54,7 @@ Parameters From 14ad82547c23460b3e3dab5266703d5a9ec010ad Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 13:37:47 +0000 Subject: [PATCH 3/4] chore: auto fixes from pre-commit.com hooks --- docs/cisco.iosxr.iosxr_banner_module.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/cisco.iosxr.iosxr_banner_module.rst b/docs/cisco.iosxr.iosxr_banner_module.rst index 85ac6dca7..46d105682 100644 --- a/docs/cisco.iosxr.iosxr_banner_module.rst +++ b/docs/cisco.iosxr.iosxr_banner_module.rst @@ -17,7 +17,7 @@ Version added: 1.0.0 Synopsis -------- -- This module will configure both login, motd, and exec banners on remote devices running Cisco IOS XR. It allows playbooks to add or remove banner text from the running configuration. +- This module will configure both exec and motd banners on remote device running Cisco IOS XR. It allows playbooks to add or remove banner text from the running configuration. @@ -54,7 +54,6 @@ Parameters From 870e3fbecbf8b546fcda12b0ba024fccb3448e09 Mon Sep 17 00:00:00 2001 From: Nathan Beard Date: Thu, 14 Aug 2025 00:15:55 -0500 Subject: [PATCH 4/4] test --- .../network/iosxr/fixtures/iosxr_banner_config.cfg | 1 + .../modules/network/iosxr/test_iosxr_banner.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/unit/modules/network/iosxr/fixtures/iosxr_banner_config.cfg b/tests/unit/modules/network/iosxr/fixtures/iosxr_banner_config.cfg index ed8e6d6dd..847a136d1 100644 --- a/tests/unit/modules/network/iosxr/fixtures/iosxr_banner_config.cfg +++ b/tests/unit/modules/network/iosxr/fixtures/iosxr_banner_config.cfg @@ -1,2 +1,3 @@ banner motd this is my motd banner banner login this is my login banner +banner exec this is my exec banner diff --git a/tests/unit/modules/network/iosxr/test_iosxr_banner.py b/tests/unit/modules/network/iosxr/test_iosxr_banner.py index 32085d51e..366a4a134 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_banner.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_banner.py @@ -94,7 +94,7 @@ def test_iosxr_banner_fail_create(self): result = self.execute_module(failed=True, changed=True) self.assertEqual( result["msg"], - "value of banner must be one of: login, motd, got: exec1", + "value of banner must be one of: login, motd, exec got: exec1", ) def test_iosxr_banner_exec1_fail_remove(self): @@ -102,7 +102,7 @@ def test_iosxr_banner_exec1_fail_remove(self): result = self.execute_module(failed=True, changed=True) self.assertIn( result["msg"], - "value of banner must be one of: login, motd, got: exec1", + "value of banner must be one of: login, motd, exec got: exec1", ) def test_iosxr_banner_motd_create(self): @@ -114,3 +114,13 @@ def test_iosxr_banner_motd_remove(self): set_module_args(dict(banner="motd", state="absent")) commands = ["no banner motd"] self.execute_module(changed=True, commands=commands) + + def test_iosxr_banner_exec_create(self): + set_module_args(dict(banner="exec", text="test\nbanner\nstring")) + commands = ["banner exec test\nbanner\nstring"] + self.execute_module(changed=True, commands=commands) + + def test_iosxr_banner_exec_remove(self): + set_module_args(dict(banner="exec", state="absent")) + commands = ["no banner exec"] + self.execute_module(changed=True, commands=commands)