diff options
author | Shawn Wilsher <656602+sdwilsh@users.noreply.github.com> | 2021-04-29 14:59:04 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-29 21:59:04 +0000 |
commit | bbfba5ce18f50e3c5284b75df99ba2d8b069c46f (patch) | |
tree | 45de27e7cff4e695f2418152c6b9522b4065bf56 | |
parent | 27481cb586042ef4ff1c15f8df46493bb84b3980 (diff) | |
download | vyos-ansible-old-bbfba5ce18f50e3c5284b75df99ba2d8b069c46f.tar.gz vyos-ansible-old-bbfba5ce18f50e3c5284b75df99ba2d8b069c46f.zip |
[firewall_global] port-groups are not added (#143)
[firewall_global] port-groups are not added
Reviewed-by: https://github.com/apps/ansible-zuul
4 files changed, 41 insertions, 8 deletions
diff --git a/changelogs/fragments/fix_port_groups.yaml b/changelogs/fragments/fix_port_groups.yaml new file mode 100644 index 0000000..abe592b --- /dev/null +++ b/changelogs/fragments/fix_port_groups.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - firewall_global - port-groups were not added (https://github.com/ansible-collections/vyos.vyos/issues/107) diff --git a/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py b/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py index 08b724a..29da3ec 100644 --- a/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py +++ b/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py @@ -36,14 +36,9 @@ class Firewall_global(ConfigBase): The vyos_firewall_global class """ - gather_subset = [ - "!all", - "!min", - ] + gather_subset = ["!all", "!min"] - gather_network_resources = [ - "firewall_global", - ] + gather_network_resources = ["firewall_global"] def __init__(self, module): super(Firewall_global, self).__init__(module) @@ -349,7 +344,7 @@ class Firewall_global(ConfigBase): h_grp = h.get("group") or {} if w: commands.extend( - self._render_grp_mem("port-group", w["group"], h_grp, opr) + self._render_grp_mem("port_group", w["group"], h_grp, opr) ) commands.extend( self._render_grp_mem( diff --git a/tests/unit/modules/network/vyos/fixtures/vyos_firewall_global_config.cfg b/tests/unit/modules/network/vyos/fixtures/vyos_firewall_global_config.cfg index 2a2a8e8..6c275a3 100644 --- a/tests/unit/modules/network/vyos/fixtures/vyos_firewall_global_config.cfg +++ b/tests/unit/modules/network/vyos/fixtures/vyos_firewall_global_config.cfg @@ -4,3 +4,5 @@ set firewall group address-group RND-HOSTS address 192.0.2.5 set firewall group address-group RND-HOSTS description 'This group has the Management hosts address lists' set firewall group network-group RND network 192.0.2.0/24 set firewall group network-group RND description 'This group has the Management network addresses' +set firewall group port-group SSH port 22 +set firewall group port-group SSH description 'This group has the ssh ports' diff --git a/tests/unit/modules/network/vyos/test_vyos_firewall_global.py b/tests/unit/modules/network/vyos/test_vyos_firewall_global.py index 0697f6e..fa40d7c 100644 --- a/tests/unit/modules/network/vyos/test_vyos_firewall_global.py +++ b/tests/unit/modules/network/vyos/test_vyos_firewall_global.py @@ -122,6 +122,13 @@ class TestVyosFirewallRulesModule(TestVyosModule): members=[dict(address="192.0.1.0/24")], ) ], + port_group=[ + dict( + name="TELNET", + description="This group has the telnet ports", + members=[dict(port="23")], + ) + ], ), ), state="merged", @@ -136,6 +143,9 @@ class TestVyosFirewallRulesModule(TestVyosModule): "set firewall group network-group MGMT network 192.0.1.0/24", "set firewall group network-group MGMT description 'This group has the Management network addresses'", "set firewall group network-group MGMT", + "set firewall group port-group TELNET port 23", + "set firewall group port-group TELNET description 'This group has the telnet ports'", + "set firewall group port-group TELNET", "set firewall ip-src-route 'enable'", "set firewall receive-redirects 'disable'", "set firewall send-redirects 'enable'", @@ -175,6 +185,13 @@ class TestVyosFirewallRulesModule(TestVyosModule): members=[dict(address="192.0.2.0/24")], ) ], + port_group=[ + dict( + name="SSH", + description="This group has the ssh ports", + members=[dict(port="22")], + ) + ], ) ), state="merged", @@ -205,6 +222,13 @@ class TestVyosFirewallRulesModule(TestVyosModule): members=[dict(address="192.0.2.0/24")], ) ], + port_group=[ + dict( + name="SSH", + description="This group has the ssh ports", + members=[dict(port="2222")], + ) + ], ) ), state="replaced", @@ -215,6 +239,8 @@ class TestVyosFirewallRulesModule(TestVyosModule): "delete firewall group address-group RND-HOSTS address 192.0.2.5", "set firewall group address-group RND-HOSTS address 192.0.2.7", "set firewall group address-group RND-HOSTS address 192.0.2.9", + "delete firewall group port-group SSH port 22", + "set firewall group port-group SSH port 2222", ] self.execute_module(changed=True, commands=commands) @@ -241,6 +267,13 @@ class TestVyosFirewallRulesModule(TestVyosModule): members=[dict(address="192.0.2.0/24")], ) ], + port_group=[ + dict( + name="SSH", + description="This group has the ssh ports", + members=[dict(port="22")], + ) + ], ) ), state="replaced", |