summaryrefslogtreecommitdiff
path: root/manifests/wireguard_peer.pp
blob: 51df0d8a3f914b781f6a534fb732f92d45b9e3a4 (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
class profiles::wireguard_peer (
  Variant[String,Sensitive[String]] $private_key,
  Array[Hash] $peers,
  String $ifname = 'wg0',
) {
  include ::profiles::wireguard

  networking::networkd_instance { $ifname:
    type              => 'netdev',
    content           => {
      'NetDev'        => {
        'Name'        => $ifname,
        'Kind'        => 'wireguard',
        'Description' => "WireGuard tunnel ${ifname}"
      },
      'WireGuard'    => {
        'PrivateKey' => $private_key,
      },
      'WireGuardPeer' => $peers,
    }
  }

  networking::networkd_instance { "${ifname}-network":
    type      => 'network',
    content   => {
      'Match' => {
        'Name' => $ifname,
      },
      'Network'   => {
        'Address' => '2001:9b1:eff:a600:22cf:30ff:fe45:629e/128',
      },
    }
  }
}