blob: 91070d562c7aa8112b12cf713056576438896738 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
class profiles::wg_exit_node (
String $iface_name = 'wg0',
Array[Hash] $peers = [],
) {
$base = "/etc/systemd/network/20-${iface_name}"
file { "${base}.netdev":
content => @("EOF")
# File managed by Puppet
[NetDev]
Name=${iface_name}
Kind=wireguard
Description=Wireguard tunnel ${iface_name}
[WireGuard]
PrivateKeyFile=/etc/wireguard/gandalf.adrift.space.key
ListenPort=51820
| EOF
}
file { "${base}.network":
content => @("EOF")
# File managed by Puppet
[Match]
Name=${iface_name}
| EOF
}
file { [
"${base}.netdev.d",
"${base}.network.d",
]:
ensure => directory,
}
$peers.each |$peer| {
file { "${base}.network.d/${peer['name']}.conf":
content => @("EOF")
[Route]
Destination=${peer['peer_address']}
| EOF
}
file { "${base}.netdev.d/${peer['name']}.conf":
content => @("EOF")
[WireGuardPeer]
PublicKey=${peer['public_key']}
AllowedIPs=${peer['peer_address']}
| EOF
}
}
}
|