Skip to content

Commit

Permalink
Add possibility to define routes
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianrakel committed Dec 7, 2021
1 parent c1ce989 commit 7d07327
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 8 additions & 1 deletion manifests/interface.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# @param description an optional string that will be added to the wireguard network interface
# @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
#
# @author Tim Meusel <[email protected]>
# @author Sebastian Rakel <[email protected]>
Expand Down Expand Up @@ -87,6 +88,7 @@
Optional[String[1]] $description = undef,
Optional[Integer[1280, 9000]] $mtu = undef,
Optional[String[1]] $public_key = undef,
Optional[Array[Hash]] $routes = undef,
) {
require wireguard
Expand Down Expand Up @@ -156,7 +158,12 @@
}
systemd::network { "${interface}.network":
content => epp("${module_name}/network.epp", { 'interface' => $interface, 'addresses' => $addresses }),
content => epp("${module_name}/network.epp",
{
'interface' => $interface,
'addresses' => $addresses,
'routes' => $routes,
}),
restart_service => true,
owner => 'root',
group => 'systemd-network',
Expand Down
7 changes: 7 additions & 0 deletions templates/network.epp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<%- |
Array[Hash] $addresses,
String[1] $interface,
Array[Hash] $routes,
| -%>
# THIS FILE IS MANAGED BY PUPPET
# based on https://dn42.dev/howto/wireguard
Expand All @@ -22,4 +23,10 @@ KeepConfiguration=yes
<%= $key %>=<%= $value %>
<% } -%>
<% } -%>
<% $routes.each |$route| { -%>

[Route]
<% $route.each |$key, $value| { -%>
<%= $key %>=<%= $value %>
<% } -%>
<% } -%>

0 comments on commit 7d07327

Please sign in to comment.