diff --git a/manifests/interface.pp b/manifests/interface.pp index 009bf03..5994e4a 100644 --- a/manifests/interface.pp +++ b/manifests/interface.pp @@ -18,7 +18,7 @@ # @param mtu configure the MTU (maximum transision unit) for the wireguard tunnel. By default linux will figure this out. You might need to lower it if you're connection through a DSL line. MTU needs to be equal on both tunnel endpoints # @param peers is an array of struct (Wireguard::Peers) for multiple peers # @param routes different routes for the systemd-networkd configuration -# @param sections additional sections for the systemd-networkd configuration +# @param extra_networkd_sections additional sections for the systemd-networkd configuration # @param private_key Define private key which should be used for this interface, if not provided a private key will be generated # @param preshared_key Define preshared key for the remote peer # @param provider The specific backend to use for this `wireguard::interface` resource @@ -97,11 +97,11 @@ # # @example Peer with one node, setup dualstack firewall rules and RoutingPolicyRule # wireguard::interface {'as2273': -# source_addresses => ['2003:4f8:c17:4cf::1', '149.9.255.4'], -# public_key => 'BcxLll1BVxGQ5DeijroesjroiesjrjvX+EBhS4vcDn0R0=', -# endpoint => 'wg.example.com:53668', -# addresses => [{'Address' => '192.168.123.6/30',},{'Address' => 'fe80::beef:1/64'},], -# sections => { +# source_addresses => ['2003:4f8:c17:4cf::1', '149.9.255.4'], +# public_key => 'BcxLll1BVxGQ5DeijroesjroiesjrjvX+EBhS4vcDn0R0=', +# endpoint => 'wg.example.com:53668', +# addresses => [{'Address' => '192.168.123.6/30',},{'Address' => 'fe80::beef:1/64'},], +# extra_networkd_sections => { # 'RoutingPolicyRule' => [ # { # 'From' => '10.0.0.0/24', @@ -130,7 +130,7 @@ Optional[Integer[1200, 9000]] $mtu = undef, Optional[String[1]] $public_key = undef, Array[Hash[String[1], Variant[String[1], Boolean]]] $routes = [], - Hash[String, Hash[Any, String]] $sections = {}, + Hash[String, Hash[String, Any]] $extra_networkd_sections = {}, Optional[String[1]] $private_key = undef, Optional[String[1]] $preshared_key = undef, Enum['systemd', 'wgquick'] $provider = 'systemd', @@ -337,21 +337,21 @@ } wireguard::provider::systemd { $interface : - ensure => $ensure, - interface => $interface, - peers => $peers + $peer, - dport => $dport, - firewall_mark => $firewall_mark, - addresses => $addresses, - description => $description, - mtu => $mtu, - routes => $routes, - sections => $sections, - default_allowlist => $wireguard::default_allowlist, + ensure => $ensure, + interface => $interface, + peers => $peers + $peer, + dport => $dport, + firewall_mark => $firewall_mark, + addresses => $addresses, + description => $description, + mtu => $mtu, + routes => $routes, + extra_networkd_sections => $extra_networkd_sections, + default_allowlist => $wireguard::default_allowlist, } } 'wgquick': { - if !empty($sections) { + if !empty($extra_networkd_sections) { warning('Systemd sections are not supported by wgquick') } diff --git a/manifests/provider/systemd.pp b/manifests/provider/systemd.pp index f522139..1a50d06 100644 --- a/manifests/provider/systemd.pp +++ b/manifests/provider/systemd.pp @@ -12,7 +12,7 @@ Optional[String[1]] $description = undef, Optional[Integer[1200, 9000]] $mtu = undef, Array[Hash[String[1], Variant[String[1], Boolean]]] $routes = [], - Hash[String, Hash[Any, String]] $sections = {}, + Hash[String, Hash[String, Any]] $extra_networkd_sections = {}, Array[Stdlib::IP::Address] $default_allowlist = [], ) { assert_private() @@ -42,10 +42,10 @@ } $network_epp_params = { - 'interface' => $interface, - 'addresses' => $addresses, - 'routes' => $routes, - 'sections' => $sections, + 'interface' => $interface, + 'addresses' => $addresses, + 'routes' => $routes, + 'extra_networkd_sections' => $extra_networkd_sections, } systemd::network { "${interface}.network": diff --git a/templates/network.epp b/templates/network.epp index 4e45fee..8307848 100644 --- a/templates/network.epp +++ b/templates/network.epp @@ -2,6 +2,7 @@ Array[Hash] $addresses, String[1] $interface, Array[Hash[String[1], Variant[String[1], Boolean]]] $routes, + Hash[String, Hash[String, Any]] $extra_networkd_sections, | -%> # THIS FILE IS MANAGED BY PUPPET # based on https://dn42.dev/howto/wireguard @@ -31,7 +32,7 @@ KeepConfiguration=yes <% } -%> <% } -%> -<% $sections.each |$section_key, $section_value| { -%> +<% $extra_networkd_sections.each |$section_key, $section_value| { -%> <% $section_value.each |$section| { -%> [<%= $section_key %>] <% $section.each |$key, $value| { -%>