Skip to content

Commit 0caa7b8

Browse files
committed
Add custom sections to systemd network
1 parent e69f10b commit 0caa7b8

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

REFERENCE.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,26 @@ wireguard::interface { 'wg0':
187187
}
188188
```
189189

190+
##### Peer with one node, setup dualstack firewall rules and RoutingPolicyRule
191+
192+
```puppet
193+
wireguard::interface {'as2273':
194+
source_addresses => ['2003:4f8:c17:4cf::1', '149.9.255.4'],
195+
public_key => 'BcxLll1BVxGQ5DeijroesjroiesjrjvX+EBhS4vcDn0R0=',
196+
endpoint => 'wg.example.com:53668',
197+
addresses => [{'Address' => '192.168.123.6/30',},{'Address' => 'fe80::beef:1/64'},],
198+
sections => {
199+
'RoutingPolicyRule' => [
200+
{
201+
'From' => '10.0.0.0/24',
202+
'Table' => '1010',
203+
'IncomingInterface' => 'as2273',
204+
},
205+
],
206+
},
207+
}
208+
```
209+
190210
#### Parameters
191211

192212
The following parameters are available in the `wireguard::interface` defined type:
@@ -208,6 +228,7 @@ The following parameters are available in the `wireguard::interface` defined typ
208228
* [`mtu`](#-wireguard--interface--mtu)
209229
* [`peers`](#-wireguard--interface--peers)
210230
* [`routes`](#-wireguard--interface--routes)
231+
* [`sections`](#-wireguard--interface--sections)
211232
* [`private_key`](#-wireguard--interface--private_key)
212233
* [`preshared_key`](#-wireguard--interface--preshared_key)
213234
* [`provider`](#-wireguard--interface--provider)
@@ -353,6 +374,15 @@ different routes for the systemd-networkd configuration
353374

354375
Default value: `[]`
355376

377+
##### <a name="-wireguard--interface--sections"></a>`sections`
378+
379+
Data type: `Hash`
380+
381+
different sections for the systemd-networkd configuration
382+
383+
Default value: `{}`
384+
385+
356386
##### <a name="-wireguard--interface--private_key"></a>`private_key`
357387

358388
Data type: `Optional[String[1]]`

manifests/provider/systemd.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
Optional[String[1]] $description = undef,
1313
Optional[Integer[1200, 9000]] $mtu = undef,
1414
Array[Hash[String[1], Variant[String[1], Boolean]]] $routes = [],
15+
Hash $sections = {},
1516
Array[Stdlib::IP::Address] $default_allowlist = [],
1617
) {
1718
assert_private()
@@ -44,6 +45,7 @@
4445
'interface' => $interface,
4546
'addresses' => $addresses,
4647
'routes' => $routes,
48+
'sections' => $sections,
4749
}
4850
4951
systemd::network { "${interface}.network":

templates/network.epp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,11 @@ KeepConfiguration=yes
3131
<% } -%>
3232
<% } -%>
3333

34+
<% $sections.each |$section_key, $section_value| { -%>
35+
<% $section_value.each |$section| { -%>
36+
[<%= $section_key %>]
37+
<% $section.each |$key, $value| { -%>
38+
<%= $key %>=<%= $value %>
39+
<% } -%>
40+
<% } -%>
41+
<% } -%>

0 commit comments

Comments
 (0)