From ca1708678e8836b9bf8f82d7a9c9b5e0c02ab731 Mon Sep 17 00:00:00 2001 From: Matthias Wiora Date: Wed, 26 Aug 2020 23:35:19 +0200 Subject: [PATCH 1/9] feat(config): allow to differentiate between running and startup config --- .../network/edgeswitch/edgeswitch_facts.py | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/plugins/modules/network/edgeswitch/edgeswitch_facts.py b/plugins/modules/network/edgeswitch/edgeswitch_facts.py index 24940420..5e6fd37e 100644 --- a/plugins/modules/network/edgeswitch/edgeswitch_facts.py +++ b/plugins/modules/network/edgeswitch/edgeswitch_facts.py @@ -38,10 +38,11 @@ community.network.edgeswitch_facts: gather_subset: all -- name: Collect only the config and default facts +- name: Collect only the running config and default facts community.network.edgeswitch_facts: gather_subset: - - config + - runningconfig + """ RETURN = """ @@ -69,7 +70,12 @@ type: str # config -ansible_net_config: +ansible_net_startupconfig: + description: The startup config from the device + returned: when config is configured + type: str + +ansible_net_runningconfig: description: The current active config from the device returned: when config is configured type: str @@ -137,15 +143,26 @@ def parse_serialnum(self, data): return match.group(1) -class Config(FactsBase): +class RunningConfig(FactsBase): COMMANDS = ['show running-config'] def populate(self): - super(Config, self).populate() + super(RunningConfig, self).populate() data = self.responses[0] if data: - self.facts['config'] = data + self.facts['runningconfig'] = data + +class StartupConfig(FactsBase): + + COMMANDS = ['show startup-config'] + + def populate(self): + super(StartupConfig, self).populate() + data = self.responses[0] + if data: + self.facts['startupconfig'] = data + class Interfaces(FactsBase): @@ -191,7 +208,8 @@ def parse_interfaces_status(self, data, interfaces): FACT_SUBSETS = dict( default=Default, - config=Config, + runningconfig=RunningConfig, + startupconfig=StartupConfig, interfaces=Interfaces, ) @@ -202,7 +220,7 @@ def main(): """main entry point for module execution """ argument_spec = dict( - gather_subset=dict(default=['!config'], type='list') + gather_subset=dict(default=['!runningconfig'], type='list') ) module = AnsibleModule(argument_spec=argument_spec, From 7a045c060a35be3ebe59948e75fe04c10bed2d47 Mon Sep 17 00:00:00 2001 From: Matthias Wiora Date: Thu, 27 Aug 2020 11:34:54 +0200 Subject: [PATCH 2/9] fix(edgeswitch): ensuring backward compatibility - runningconfig remains config and is completed by startupconfig --- .../modules/network/edgeswitch/edgeswitch_facts.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/modules/network/edgeswitch/edgeswitch_facts.py b/plugins/modules/network/edgeswitch/edgeswitch_facts.py index 5e6fd37e..1198fa3a 100644 --- a/plugins/modules/network/edgeswitch/edgeswitch_facts.py +++ b/plugins/modules/network/edgeswitch/edgeswitch_facts.py @@ -41,7 +41,7 @@ - name: Collect only the running config and default facts community.network.edgeswitch_facts: gather_subset: - - runningconfig + - config """ @@ -75,7 +75,7 @@ returned: when config is configured type: str -ansible_net_runningconfig: +ansible_net_config: description: The current active config from the device returned: when config is configured type: str @@ -143,15 +143,15 @@ def parse_serialnum(self, data): return match.group(1) -class RunningConfig(FactsBase): +class Config(FactsBase): COMMANDS = ['show running-config'] def populate(self): - super(RunningConfig, self).populate() + super(Config, self).populate() data = self.responses[0] if data: - self.facts['runningconfig'] = data + self.facts['config'] = data class StartupConfig(FactsBase): @@ -208,7 +208,7 @@ def parse_interfaces_status(self, data, interfaces): FACT_SUBSETS = dict( default=Default, - runningconfig=RunningConfig, + config=Config, startupconfig=StartupConfig, interfaces=Interfaces, ) @@ -220,7 +220,7 @@ def main(): """main entry point for module execution """ argument_spec = dict( - gather_subset=dict(default=['!runningconfig'], type='list') + gather_subset=dict(default=['!config'], type='list') ) module = AnsibleModule(argument_spec=argument_spec, From 0e6a61698c5129bf848ea59b088e9a1193b0a940 Mon Sep 17 00:00:00 2001 From: "Matthias R. Wiora" Date: Thu, 27 Aug 2020 13:03:49 +0200 Subject: [PATCH 3/9] feat(changelog): adding version change info for startupconfig Co-authored-by: Felix Fontein --- plugins/modules/network/edgeswitch/edgeswitch_facts.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/modules/network/edgeswitch/edgeswitch_facts.py b/plugins/modules/network/edgeswitch/edgeswitch_facts.py index 1198fa3a..9b296e4e 100644 --- a/plugins/modules/network/edgeswitch/edgeswitch_facts.py +++ b/plugins/modules/network/edgeswitch/edgeswitch_facts.py @@ -74,6 +74,7 @@ description: The startup config from the device returned: when config is configured type: str + version_added: 1.2.0 ansible_net_config: description: The current active config from the device From 941a49e0f1e2461d231a0f888f9c106ee8255d6c Mon Sep 17 00:00:00 2001 From: Matthias Wiora Date: Fri, 28 Aug 2020 22:46:51 +0200 Subject: [PATCH 4/9] fix(tests): ignore startupconfig as parameter --- .../plugins/modules/network/edgeswitch/test_edgeswitch_facts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/plugins/modules/network/edgeswitch/test_edgeswitch_facts.py b/tests/unit/plugins/modules/network/edgeswitch/test_edgeswitch_facts.py index 4be26fb6..aa384f47 100644 --- a/tests/unit/plugins/modules/network/edgeswitch/test_edgeswitch_facts.py +++ b/tests/unit/plugins/modules/network/edgeswitch/test_edgeswitch_facts.py @@ -51,7 +51,7 @@ def load_from_file(*args, **kwargs): self.run_commands.side_effect = load_from_file def test_edgeswitch_facts_default(self): - set_module_args(dict(gather_subset=['all', '!interfaces', '!config'])) + set_module_args(dict(gather_subset=['all', '!interfaces', '!config', '!startupconfig'])) result = self.execute_module() facts = result.get('ansible_facts') self.assertEqual(len(facts), 5) From 054098db119149753386298a880a3a5b4f5c7d89 Mon Sep 17 00:00:00 2001 From: Matthias Wiora Date: Fri, 28 Aug 2020 23:36:19 +0200 Subject: [PATCH 5/9] fix(lint): satify linter - blank lines missmatch --- plugins/modules/network/edgeswitch/edgeswitch_facts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/network/edgeswitch/edgeswitch_facts.py b/plugins/modules/network/edgeswitch/edgeswitch_facts.py index 1198fa3a..39dfc90a 100644 --- a/plugins/modules/network/edgeswitch/edgeswitch_facts.py +++ b/plugins/modules/network/edgeswitch/edgeswitch_facts.py @@ -153,6 +153,7 @@ def populate(self): if data: self.facts['config'] = data + class StartupConfig(FactsBase): COMMANDS = ['show startup-config'] @@ -164,7 +165,6 @@ def populate(self): self.facts['startupconfig'] = data - class Interfaces(FactsBase): COMMANDS = [ From 835be4cb83aab7fcad85505a06f566fdf6ec6bac Mon Sep 17 00:00:00 2001 From: Matthias Wiora Date: Wed, 2 Sep 2020 10:04:12 +0200 Subject: [PATCH 6/9] feat(changelog): adding changelog fragment --- changelogs/fragments/105_edgeswitch_add-startupconfig.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/105_edgeswitch_add-startupconfig.yml diff --git a/changelogs/fragments/105_edgeswitch_add-startupconfig.yml b/changelogs/fragments/105_edgeswitch_add-startupconfig.yml new file mode 100644 index 00000000..d6409d8e --- /dev/null +++ b/changelogs/fragments/105_edgeswitch_add-startupconfig.yml @@ -0,0 +1,2 @@ +feature: + - edgeswitch_facts - Added `startupconfig` to facts module - to allow the comparision between startup and running config. From c775a7f30d82b389abda11d11c0db9e662142aaf Mon Sep 17 00:00:00 2001 From: Matthias Wiora Date: Wed, 2 Sep 2020 10:16:40 +0200 Subject: [PATCH 7/9] fix(changelog): changelog fragment as required --- changelogs/fragments/105_edgeswitch_add-startupconfig.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/105_edgeswitch_add-startupconfig.yml b/changelogs/fragments/105_edgeswitch_add-startupconfig.yml index d6409d8e..a4ab82b1 100644 --- a/changelogs/fragments/105_edgeswitch_add-startupconfig.yml +++ b/changelogs/fragments/105_edgeswitch_add-startupconfig.yml @@ -1,2 +1,2 @@ -feature: +minor_changes: - edgeswitch_facts - Added `startupconfig` to facts module - to allow the comparision between startup and running config. From 82d6f527d68629e4821d09b74821ac79a073af15 Mon Sep 17 00:00:00 2001 From: Matthias Wiora Date: Wed, 2 Sep 2020 10:47:04 +0200 Subject: [PATCH 8/9] trigger(): retrigger --- changelogs/fragments/105_edgeswitch_add-startupconfig.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/105_edgeswitch_add-startupconfig.yml b/changelogs/fragments/105_edgeswitch_add-startupconfig.yml index a4ab82b1..411416a0 100644 --- a/changelogs/fragments/105_edgeswitch_add-startupconfig.yml +++ b/changelogs/fragments/105_edgeswitch_add-startupconfig.yml @@ -1,2 +1,2 @@ minor_changes: - - edgeswitch_facts - Added `startupconfig` to facts module - to allow the comparision between startup and running config. + - edgeswitch_facts - Added `startupconfig` to facts module - to allow the comparision between startup and running config From 55fa204489df9b71c23bc3b8cb51207a83552baf Mon Sep 17 00:00:00 2001 From: "Matthias R. Wiora" Date: Thu, 3 Sep 2020 08:35:24 +0200 Subject: [PATCH 9/9] Update changelogs/fragments/105_edgeswitch_add-startupconfig.yml Co-authored-by: Felix Fontein --- changelogs/fragments/105_edgeswitch_add-startupconfig.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/105_edgeswitch_add-startupconfig.yml b/changelogs/fragments/105_edgeswitch_add-startupconfig.yml index 411416a0..6fc66cff 100644 --- a/changelogs/fragments/105_edgeswitch_add-startupconfig.yml +++ b/changelogs/fragments/105_edgeswitch_add-startupconfig.yml @@ -1,2 +1,2 @@ minor_changes: - - edgeswitch_facts - Added `startupconfig` to facts module - to allow the comparision between startup and running config + - edgeswitch_facts - added ``startupconfig`` to facts module - to allow the comparision between startup and running config (https://github.com/ansible-collections/community.network/pull/105).