From: Tom Hughes Date: Mon, 20 Mar 2023 17:41:41 +0000 (+0000) Subject: Improve naming of wireguard configuration files X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/2170e9c9897b544b7188cf3fd4cea8498121ff7f Improve naming of wireguard configuration files --- diff --git a/cookbooks/networking/recipes/default.rb b/cookbooks/networking/recipes/default.rb index 4d3974b96..540d858fc 100644 --- a/cookbooks/networking/recipes/default.rb +++ b/cookbooks/networking/recipes/default.rb @@ -309,32 +309,40 @@ if node[:networking][:wireguard][:enabled] end end - template "/etc/systemd/network/wireguard.netdev" do + file "/etc/systemd/network/wireguard.netdev" do + action :delete + end + + template "/etc/systemd/network/10-wg0.netdev" do source "wireguard.netdev.erb" owner "root" group "systemd-network" mode "640" + notifies :run, "execute[networkctl-delete-wg0]" + notifies :run, "execute[networkctl-reload]" + end + + file "/etc/systemd/network/wireguard.network" do + action :delete end - template "/etc/systemd/network/wireguard.network" do + template "/etc/systemd/network/10-wg0.network" do source "wireguard.network.erb" owner "root" group "root" mode "644" + notifies :run, "execute[networkctl-reload]" end execute "networkctl-delete-wg0" do action :nothing command "networkctl delete wg0" - subscribes :run, "template[/etc/systemd/network/wireguard.netdev]" only_if { ::File.exist?("/sys/class/net/wg0") } end execute "networkctl-reload" do action :nothing command "networkctl reload" - subscribes :run, "template[/etc/systemd/network/wireguard.netdev]" - subscribes :run, "template[/etc/systemd/network/wireguard.network]" not_if { kitchen? } end end