system: enable homelab-deploy listener for all vault hosts
All checks were successful
Run nix flake check / flake-check (push) Successful in 2m4s
All checks were successful
Run nix flake check / flake-check (push) Successful in 2m4s
Add system/homelab-deploy.nix module that automatically enables the listener on all hosts with vault.enable=true. Uses homelab.host.tier and homelab.host.role for NATS subject subscriptions. - Add homelab-deploy access to all host AppRole policies - Remove manual listener config from vaulttest01 (now handled by system module) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -101,28 +101,6 @@ in
|
|||||||
services = [ "vault-test" ];
|
services = [ "vault-test" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
# Homelab-deploy listener NKey
|
|
||||||
vault.secrets.homelab-deploy-nkey = {
|
|
||||||
secretPath = "shared/homelab-deploy/listener-nkey";
|
|
||||||
extractKey = "nkey";
|
|
||||||
};
|
|
||||||
|
|
||||||
# Enable homelab-deploy listener
|
|
||||||
services.homelab-deploy.listener = {
|
|
||||||
enable = true;
|
|
||||||
tier = "test";
|
|
||||||
role = "vault";
|
|
||||||
natsUrl = "nats://nats1.home.2rjus.net:4222";
|
|
||||||
nkeyFile = "/run/secrets/homelab-deploy-nkey";
|
|
||||||
flakeUrl = "git+https://git.t-juice.club/torjus/nixos-servers.git";
|
|
||||||
};
|
|
||||||
|
|
||||||
# Ensure listener starts after vault secret is available
|
|
||||||
systemd.services.homelab-deploy-listener = {
|
|
||||||
after = [ "vault-secret-homelab-deploy-nkey.service" ];
|
|
||||||
requires = [ "vault-secret-homelab-deploy-nkey.service" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
# Create a test service that uses the secret
|
# Create a test service that uses the secret
|
||||||
systemd.services.vault-test = {
|
systemd.services.vault-test = {
|
||||||
description = "Test Vault secret fetching";
|
description = "Test Vault secret fetching";
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
imports = [
|
imports = [
|
||||||
./acme.nix
|
./acme.nix
|
||||||
./autoupgrade.nix
|
./autoupgrade.nix
|
||||||
|
./homelab-deploy.nix
|
||||||
./monitoring
|
./monitoring
|
||||||
./motd.nix
|
./motd.nix
|
||||||
./packages.nix
|
./packages.nix
|
||||||
|
|||||||
31
system/homelab-deploy.nix
Normal file
31
system/homelab-deploy.nix
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.vault;
|
||||||
|
hostCfg = config.homelab.host;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
# Fetch listener NKey from Vault
|
||||||
|
vault.secrets.homelab-deploy-nkey = {
|
||||||
|
secretPath = "shared/homelab-deploy/listener-nkey";
|
||||||
|
extractKey = "nkey";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Enable homelab-deploy listener
|
||||||
|
services.homelab-deploy.listener = {
|
||||||
|
enable = true;
|
||||||
|
tier = hostCfg.tier;
|
||||||
|
role = hostCfg.role;
|
||||||
|
natsUrl = "nats://nats1.home.2rjus.net:4222";
|
||||||
|
nkeyFile = "/run/secrets/homelab-deploy-nkey";
|
||||||
|
flakeUrl = "git+https://git.t-juice.club/torjus/nixos-servers.git";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Ensure listener starts after vault secret is available
|
||||||
|
systemd.services.homelab-deploy-listener = {
|
||||||
|
after = [ "vault-secret-homelab-deploy-nkey.service" ];
|
||||||
|
requires = [ "vault-secret-homelab-deploy-nkey.service" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -30,6 +30,7 @@ locals {
|
|||||||
paths = [
|
paths = [
|
||||||
"secret/data/hosts/ha1/*",
|
"secret/data/hosts/ha1/*",
|
||||||
"secret/data/shared/backup/*",
|
"secret/data/shared/backup/*",
|
||||||
|
"secret/data/shared/homelab-deploy/*",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,6 +39,7 @@ locals {
|
|||||||
"secret/data/hosts/monitoring01/*",
|
"secret/data/hosts/monitoring01/*",
|
||||||
"secret/data/shared/backup/*",
|
"secret/data/shared/backup/*",
|
||||||
"secret/data/shared/nats/*",
|
"secret/data/shared/nats/*",
|
||||||
|
"secret/data/shared/homelab-deploy/*",
|
||||||
]
|
]
|
||||||
extra_policies = ["prometheus-metrics"]
|
extra_policies = ["prometheus-metrics"]
|
||||||
}
|
}
|
||||||
@@ -46,18 +48,21 @@ locals {
|
|||||||
"nats1" = {
|
"nats1" = {
|
||||||
paths = [
|
paths = [
|
||||||
"secret/data/hosts/nats1/*",
|
"secret/data/hosts/nats1/*",
|
||||||
|
"secret/data/shared/homelab-deploy/*",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
"jelly01" = {
|
"jelly01" = {
|
||||||
paths = [
|
paths = [
|
||||||
"secret/data/hosts/jelly01/*",
|
"secret/data/hosts/jelly01/*",
|
||||||
|
"secret/data/shared/homelab-deploy/*",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
"pgdb1" = {
|
"pgdb1" = {
|
||||||
paths = [
|
paths = [
|
||||||
"secret/data/hosts/pgdb1/*",
|
"secret/data/hosts/pgdb1/*",
|
||||||
|
"secret/data/shared/homelab-deploy/*",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +71,7 @@ locals {
|
|||||||
paths = [
|
paths = [
|
||||||
"secret/data/hosts/ns1/*",
|
"secret/data/hosts/ns1/*",
|
||||||
"secret/data/shared/dns/*",
|
"secret/data/shared/dns/*",
|
||||||
|
"secret/data/shared/homelab-deploy/*",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,6 +79,7 @@ locals {
|
|||||||
paths = [
|
paths = [
|
||||||
"secret/data/hosts/ns2/*",
|
"secret/data/hosts/ns2/*",
|
||||||
"secret/data/shared/dns/*",
|
"secret/data/shared/dns/*",
|
||||||
|
"secret/data/shared/homelab-deploy/*",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,6 +87,7 @@ locals {
|
|||||||
"http-proxy" = {
|
"http-proxy" = {
|
||||||
paths = [
|
paths = [
|
||||||
"secret/data/hosts/http-proxy/*",
|
"secret/data/hosts/http-proxy/*",
|
||||||
|
"secret/data/shared/homelab-deploy/*",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,10 +95,10 @@ locals {
|
|||||||
"nix-cache01" = {
|
"nix-cache01" = {
|
||||||
paths = [
|
paths = [
|
||||||
"secret/data/hosts/nix-cache01/*",
|
"secret/data/hosts/nix-cache01/*",
|
||||||
|
"secret/data/shared/homelab-deploy/*",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Vault test host with homelab-deploy access
|
|
||||||
"vaulttest01" = {
|
"vaulttest01" = {
|
||||||
paths = [
|
paths = [
|
||||||
"secret/data/hosts/vaulttest01/*",
|
"secret/data/hosts/vaulttest01/*",
|
||||||
|
|||||||
Reference in New Issue
Block a user