refactor(infra): migrate ddclient configuration to standalone template
- Extract hardcoded `ddclient.conf` into a dedicated file to improve readability and enable native syntax highlighting. - Refactor `dynu.nix` to use `builtins.readFile` and `builtins.replaceStrings` for dynamic secret injection. - Harden `ddclient` operational parameters: Remove `daemon=0` to force foreground execution and add `usev4=webv4` for explicit WAN IP discovery. Rationale: Eliminates fragile string-concatenation logic in Nix files and solves IP-resolution failures by ensuring the service executes in a controlled, foreground-reporting state.
This commit is contained in:
1 parent
4a9b4de27d
commit
25c9699ac4
2 files changed
+19
-13
No files matched your search
@@ -0,0 +1,11 @@
|
|||||||
|
# General configuration
|
||||||
|
syslog=yes
|
||||||
|
pid=/run/ddclient/ddclient.pid
|
||||||
|
usev4=webv4
|
||||||
|
|
||||||
|
# Provider definition using credentials decrypted at runtime
|
||||||
|
protocol=dyndns2
|
||||||
|
server=api.dynu.com
|
||||||
|
login=@dynu_user@
|
||||||
|
password=@dynu_password@
|
||||||
|
@dynu_domain@
|
||||||
+8
-13
@@ -25,19 +25,14 @@ in
|
|||||||
# Assemble the ddclient config file securely at boot time in /run/secrets/
|
# Assemble the ddclient config file securely at boot time in /run/secrets/
|
||||||
# Defaults to owner root:root (which avoids dynamic user evaluation issues)
|
# Defaults to owner root:root (which avoids dynamic user evaluation issues)
|
||||||
sops.templates."ddclient.conf" = {
|
sops.templates."ddclient.conf" = {
|
||||||
content = ''
|
content = builtins.replaceStrings
|
||||||
# General configuration
|
[ "@dynu_user@" "@dynu_password@" "@dynu_domain@" ]
|
||||||
daemon=0
|
[
|
||||||
syslog=yes
|
config.sops.placeholder.dynu_user
|
||||||
pid=/run/ddclient/ddclient.pid
|
config.sops.placeholder.dynu_password
|
||||||
|
config.sops.placeholder.dynu_domain
|
||||||
# Provider definition using credentials decrypted at runtime
|
]
|
||||||
protocol=dyndns2
|
(builtins.readFile ./ddclient.conf);
|
||||||
server=api.dynu.com
|
|
||||||
login=${config.sops.placeholder.dynu_user}
|
|
||||||
password=${config.sops.placeholder.dynu_password}
|
|
||||||
${config.sops.placeholder.dynu_domain}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# 2. Enable ddclient and feed it the decrypted configuration template via systemd credentials
|
# 2. Enable ddclient and feed it the decrypted configuration template via systemd credentials
|
||||||
|
|||||||
Reference in new issue
Block a user