s3-replicate is the same rclone sync with the same delete limit, run by the rclone package instead of its image. The certificate push keeps its shape: ops reads Traefik's acme.json and sends each certificate over SSH with a key that may run one command on services, from ops only. The key is now a sops secret with its public half in the config, instead of being generated on the host, so a rebuilt pair works without a manual step. Tried on the rehearsal pair with a throwaway certificate; any other command is refused. Assisted-by: Claude:fable-5-2
40 lines
1.2 KiB
Nix
40 lines
1.2 KiB
Nix
# XMPP certificates come from Traefik here (router xmpp-cert requests
|
|
# xmpp.asxp.io + conference.; asxp.io is the site's own certificate) and
|
|
# are pushed to ejabberd on asxpio-services on every renewal.
|
|
{ config, pkgs, ... }:
|
|
let
|
|
sync = pkgs.writers.writePython3 "xmpp-cert-sync" {
|
|
flakeIgnore = [ "E501" ];
|
|
} (builtins.readFile ./xmpp-cert-sync.py);
|
|
in
|
|
{
|
|
sops.secrets."xmpp_cert_sync/ssh_key" = { };
|
|
|
|
systemd.services.xmpp-cert-sync = {
|
|
description = "Push the XMPP certificate from Traefik to ejabberd";
|
|
path = [
|
|
pkgs.openssh
|
|
pkgs.openssl
|
|
pkgs.coreutils
|
|
];
|
|
environment.XMPP_CERT_KEY = config.sops.secrets."xmpp_cert_sync/ssh_key".path;
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
ExecStart = sync;
|
|
StateDirectory = "xmpp-cert-sync";
|
|
};
|
|
};
|
|
systemd.paths.xmpp-cert-sync = {
|
|
description = "Watch Traefik's acme.json for a renewed XMPP certificate";
|
|
wantedBy = [ "paths.target" ];
|
|
pathConfig.PathChanged = "/var/lib/traefik/acme.json";
|
|
};
|
|
systemd.timers.xmpp-cert-sync = {
|
|
description = "Daily XMPP certificate check (fallback for the path unit)";
|
|
wantedBy = [ "timers.target" ];
|
|
timerConfig = {
|
|
OnCalendar = "*-*-* 05:40:00";
|
|
Persistent = true;
|
|
};
|
|
};
|
|
}
|