diff options
5 files changed, 26 insertions, 1 deletions
diff --git a/changelogs/fragments/parse_wireguard_interface.yml b/changelogs/fragments/parse_wireguard_interface.yml new file mode 100644 index 0000000..a353afb --- /dev/null +++ b/changelogs/fragments/parse_wireguard_interface.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - Enabled addition and parsing of wireguard interface. diff --git a/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py b/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py index 13f22e1..ea3933c 100644 --- a/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py +++ b/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py @@ -60,7 +60,7 @@ class InterfacesFacts(object): objs = [] interface_names = findall( - r"^set interfaces (?:ethernet|bonding|vti|loopback|vxlan|openvpn) (?:\'*)(\S+)(?:\'*)", + r"^set interfaces (?:ethernet|bonding|vti|loopback|vxlan|openvpn|wireguard) (?:\'*)(\S+)(?:\'*)", data, M, ) diff --git a/plugins/module_utils/network/vyos/utils/utils.py b/plugins/module_utils/network/vyos/utils/utils.py index f6ac9f5..43f3fc9 100644 --- a/plugins/module_utils/network/vyos/utils/utils.py +++ b/plugins/module_utils/network/vyos/utils/utils.py @@ -38,6 +38,8 @@ def get_interface_type(interface): return "loopback" elif interface.startswith("vtun"): return "openvpn" + elif interface.startswith("wg"): + return "wireguard" def dict_delete(base, comparable): diff --git a/tests/unit/modules/network/vyos/fixtures/vyos_interfaces_config.cfg b/tests/unit/modules/network/vyos/fixtures/vyos_interfaces_config.cfg index 90f120c..bed0b01 100644 --- a/tests/unit/modules/network/vyos/fixtures/vyos_interfaces_config.cfg +++ b/tests/unit/modules/network/vyos/fixtures/vyos_interfaces_config.cfg @@ -4,4 +4,5 @@ set interfaces ethernet eth1 description 'test-interface' set interfaces ethernet eth2 hw-id '08:00:27:04:85:99' set interfaces ethernet eth3 hw-id '08:00:27:1c:82:d1' set interfaces ethernet eth3 description 'Ethernet 3' +set interfaces wireguard wg02 description 'wire guard int 2' set interfaces loopback 'lo' diff --git a/tests/unit/modules/network/vyos/test_vyos_interfaces.py b/tests/unit/modules/network/vyos/test_vyos_interfaces.py index 40770df..a0f5174 100644 --- a/tests/unit/modules/network/vyos/test_vyos_interfaces.py +++ b/tests/unit/modules/network/vyos/test_vyos_interfaces.py @@ -86,6 +86,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule): config=[ dict(name="bond1", description="Bond - 1", enabled=True), dict(name="vtun1", description="vtun - 1", enabled=True), + dict(name="wg01", description="wg - 1", enabled=True), ], state="merged", ) @@ -94,9 +95,26 @@ class TestVyosFirewallInterfacesModule(TestVyosModule): commands = [ "set interfaces bonding bond1 description 'Bond - 1'", "set interfaces openvpn vtun1 description 'vtun - 1'", + "set interfaces wireguard wg01 description 'wg - 1'", ] self.execute_module(changed=True, commands=commands) + def test_vyos_interfaces_merged_idempotent(self): + set_module_args( + dict( + config=[ + dict( + name="wg02", + description="wire guard int 2", + enabled=True, + ), + ], + state="merged", + ) + ) + + self.execute_module(changed=False, commands=[]) + def test_vyos_interfaces_merged_newinterface(self): set_module_args( dict( @@ -169,6 +187,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule): "set interfaces ethernet eth4 description 'Ethernet 4'", "set interfaces ethernet eth4 duplex 'auto'", "set interfaces ethernet eth4 speed 'auto'", + "delete interfaces wireguard wg02 description", "delete interfaces ethernet eth3 description", ] self.execute_module(changed=True, commands=commands) |