X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/d67b78773673b939831588836bee081d1360fd3c..dd7f629ab3f1404a2a3ea5a9c4e28c416ecb6e3b:/cookbooks/networking/templates/default/wireguard.netdev.erb?ds=sidebyside diff --git a/cookbooks/networking/templates/default/wireguard.netdev.erb b/cookbooks/networking/templates/default/wireguard.netdev.erb index 7f7ef3114..248bde252 100644 --- a/cookbooks/networking/templates/default/wireguard.netdev.erb +++ b/cookbooks/networking/templates/default/wireguard.netdev.erb @@ -3,13 +3,21 @@ Name=wg0 Kind=wireguard [WireGuard] +<% if node[:lsb][:release].to_f < 20.04 -%> +PrivateKey=<%= IO.read("/var/lib/systemd/wireguard/private.key").chomp %> +<% else -%> PrivateKeyFile=/var/lib/systemd/wireguard/private.key +<% end -%> ListenPort=51820 -<% node[:networking][:wireguard][:peers].each do |peer| -%> +<% node[:networking][:wireguard][:peers].sort_by { |p| p[:public_key] }.each do |peer| -%> [WireGuardPeer] PublicKey=<%= peer[:public_key] %> +<% if node[:lsb][:release].to_f < 20.04 -%> +PresharedKey=<%= IO.read("/var/lib/systemd/wireguard/preshared.key").chomp %> +<% else -%> PresharedKeyFile=/var/lib/systemd/wireguard/preshared.key +<% end -%> AllowedIPs=<%= Array(peer[:allowed_ips]).sort.join(",") %> <% if peer[:endpoint] -%> Endpoint=<%= peer[:endpoint] %>