Migrate to new tailscale config
* use the new config option isntead of custom service * lower the log spam
This commit is contained in:
parent
6c0aebab4f
commit
db580ad606
1 changed files with 5 additions and 23 deletions
|
@ -13,6 +13,10 @@ in {
|
||||||
services.tailscale = {
|
services.tailscale = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = tailscale;
|
package = tailscale;
|
||||||
|
authKeyFile = "/run/secrets/tailscale-key-${config.networking.hostName}";
|
||||||
|
};
|
||||||
|
systemd.services.tailscaled = {
|
||||||
|
serviceConfig.LogLevelMax = "notice";
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.firewall = {
|
networking.firewall = {
|
||||||
|
@ -21,28 +25,6 @@ in {
|
||||||
};
|
};
|
||||||
sops.secrets."tailscale-key-${config.networking.hostName}" = {
|
sops.secrets."tailscale-key-${config.networking.hostName}" = {
|
||||||
sopsFile = ./keys.sops.yaml;
|
sopsFile = ./keys.sops.yaml;
|
||||||
restartUnits = ["tailscale-auth.service"];
|
restartUnits = ["tailscaled-autoconnect.service"];
|
||||||
};
|
|
||||||
systemd.services.tailscale-auth = {
|
|
||||||
description = "Auth with tailscale";
|
|
||||||
|
|
||||||
after = ["network-pre.target" "tailscale.service"];
|
|
||||||
wants = ["network-pre.target" "tailscale.service"];
|
|
||||||
wantedBy = ["multi-user.target"];
|
|
||||||
|
|
||||||
serviceConfig.Type = "oneshot";
|
|
||||||
|
|
||||||
script = ''
|
|
||||||
sleep 2
|
|
||||||
|
|
||||||
status="$(${tailscale}/bin/tailscale status -json | ${pkgs.jq}/bin/jq -r .BackendState)"
|
|
||||||
if [ $status = "Running" ]; then # if so, then do nothing
|
|
||||||
echo "already connected"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "$status, reauthing"
|
|
||||||
${tailscale}/bin/tailscale up --authkey `cat /run/secrets/tailscale-key-${config.networking.hostName}`
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue