diff --git a/wireguard.yml b/wireguard.yml index c58dee0..1502bf1 100644 --- a/wireguard.yml +++ b/wireguard.yml @@ -78,6 +78,45 @@ route: yes interface_in: wg0 + - name: Restart service for config changes + copy: + dest: "/etc/systemd/system/wg-ui-restart.service" + content: | + [Unit] + Description=Restart WireGuard + After=network.target + + [Service] + Type=oneshot + ExecStart=/usr/bin/systemctl restart wg-quick@wg0.service + + [Install] + RequiredBy=wg-ui-restart.path + + - name: 'start wg-ui-restart.service' + systemd: + name: wg-ui-restart.service + enabled: true + + - name: Restart service for config changes + copy: + dest: "/etc/systemd/system/wg-ui-restart.path" + content: | + [Unit] + Description=Watch /etc/wireguard/wg0.conf for changes + + [Path] + PathModified=/etc/wireguard/wg0.conf + + [Install] + WantedBy=multi-user.target + + - name: 'add wg-ui-restart.path to startup' + systemd: + name: wg-ui-restart.path + state: started + enabled: true + - name: 'add wireguard to startup' command: systemctl enable wg-quick@wg0.service args: