Skip to content

Commit

Permalink
Add some comments to wgquick config file
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianrakel committed Aug 8, 2022
1 parent 7bc81b7 commit 41fc563
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
24 changes: 12 additions & 12 deletions manifests/interface.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# @param peers is an array of struct (Wireguard::Peers) for multiple peers
# @param routes different routes 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 which should be used for this interface
# @param preshared_key Define preshared key for the remote peer
# @param provider The specific backend to use for this `wireguard::interface` resource
#
# @author Tim Meusel <[email protected]>
Expand Down Expand Up @@ -177,21 +177,21 @@
case $provider {
'systemd': {
wireguard::provider::systemd { $interface :
interface => $interface,
peers => $peers + $peer,
dport => $dport,
addresses => $addresses,
description => $description,
mtu => $mtu,
routes => $routes,
interface => $interface,
peers => $peers + $peer,
dport => $dport,
addresses => $addresses,
description => $description,
mtu => $mtu,
routes => $routes,
}
}
'wgquick': {
wireguard::provider::wgquick { $interface :
interface => $interface,
peers => $peers + $peer,
dport => $dport,
addresses => $addresses,
interface => $interface,
peers => $peers + $peer,
dport => $dport,
addresses => $addresses,
}
}
default: {
Expand Down
12 changes: 5 additions & 7 deletions manifests/provider/systemd.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@
Optional[String[1]] $description = undef,
Optional[Integer[1280, 9000]] $mtu = undef,
Array[Hash[String[1], Variant[String[1], Boolean]]] $routes = [],
Optional[String[1]] $preshared_key = undef,
) {
assert_private()
systemd::network { "${interface}.netdev":
content => epp("${module_name}/netdev.epp", {
'interface' => $interface,
'dport' => $dport,
'description' => $description,
'mtu' => $mtu,
'peers' => $peers,
'preshared_key' => $preshared_key,
'interface' => $interface,
'dport' => $dport,
'description' => $description,
'mtu' => $mtu,
'peers' => $peers,
}),
restart_service => true,
owner => 'root',
Expand Down
10 changes: 4 additions & 6 deletions manifests/provider/wgquick.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
Wireguard::Peers $peers = [],
Integer[1024, 65000] $dport = Integer(regsubst($title, '^\D+(\d+)$', '\1')),
Array[Hash[String,Variant[Stdlib::IP::Address::V4::CIDR,Stdlib::IP::Address::V6::CIDR]]] $addresses = [],
Optional[String[1]] $preshared_key = undef,
) {
assert_private()
$params = {
'interface' => $interface,
'dport' => $dport,
'peers' => $peers,
'addresses' => $addresses,
'preshared_key' => $preshared_key,
'interface' => $interface,
'dport' => $dport,
'peers' => $peers,
'addresses' => $addresses,
}
file { "/etc/wireguard/${interface}.conf":
Expand Down
4 changes: 4 additions & 0 deletions templates/wireguard_conf.epp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Array[Hash] $addresses,
Optional[String[1]] $preshared_key,
| -%>
# THIS FILE IS MANAGED BY PUPPET
[Interface]
<% $addresses.each |$address| { -%>
Address = <%= $address['Address'] %>
Expand All @@ -13,6 +14,9 @@ ListenPort = <%= $dport %>
PostUp = wg set %i private-key /etc/wireguard/<%= $interface %>
<% $peers.each |$peer| { -%>

<% if $peer['description'] { -%>
# <%= $peer['description'] %>
<% } -%>
[Peer]
PublicKey=<%= $peer['public_key'] %>
<% if $peer['endpoint'] { -%>
Expand Down

0 comments on commit 41fc563

Please sign in to comment.