Add service accounts and systemd hardening

- cloudflared: create dedicated service account, run as non-root with
  ProtectSystem=strict and full hardening directives
- cloudflared: skip credentials overwrite when existing tunnel has valid
  credentials on disk; delete and recreate if credentials are missing
- wireguard: add systemd drop-in with ProtectHome, ProtectClock,
  ProtectHostname, ProtectKernelLogs, PrivateTmp

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
n0mad1k
2026-03-10 13:46:24 -04:00
parent 1eff254a66
commit d687423c22
2 changed files with 54 additions and 9 deletions
+22
View File
@@ -116,6 +116,28 @@
args:
creates: /etc/wireguard/clients/client1.conf
- name: Create WireGuard systemd override directory
file:
path: /etc/systemd/system/wg-quick@wg0.service.d
state: directory
mode: "0755"
- name: Deploy WireGuard systemd hardening override
copy:
dest: /etc/systemd/system/wg-quick@wg0.service.d/hardening.conf
content: |
[Service]
ProtectHome=true
ProtectClock=true
ProtectHostname=true
ProtectKernelLogs=true
PrivateTmp=true
mode: "0644"
- name: Reload systemd daemon
systemd:
daemon_reload: true
- name: Enable and start WireGuard
systemd:
name: wg-quick@wg0