cluster/lib: inject secrets into agenix modules
This commit is contained in:
parent
8adc26c5c3
commit
5727bdb37e
1 changed files with 15 additions and 4 deletions
|
@ -2,10 +2,21 @@
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
getHostConfigurations = hostName: svcConfig:
|
getHostConfigurations = hostName: svcName: svcConfig: let
|
||||||
lib.mapAttrsToList (groupName: _: svcConfig.nixos.${groupName})
|
serviceConfigs =
|
||||||
(lib.filterAttrs (_: lib.elem hostName) svcConfig.nodes);
|
lib.mapAttrsToList (groupName: _: svcConfig.nixos.${groupName})
|
||||||
|
(lib.filterAttrs (_: lib.elem hostName) svcConfig.nodes);
|
||||||
|
|
||||||
|
secretsConfig.age.secrets = lib.mapAttrs' (secretName: secretConfig: {
|
||||||
|
name = "cluster-${svcName}-${secretName}";
|
||||||
|
value = {
|
||||||
|
inherit (secretConfig) path mode owner group;
|
||||||
|
file = ../secrets/${svcName}-${secretName}${lib.optionalString (!secretConfig.shared) "-${hostName}"}.age;
|
||||||
|
};
|
||||||
|
}) (lib.filterAttrs (_: secret: lib.any (node: node == hostName) secret.nodes) svcConfig.secrets);
|
||||||
|
in serviceConfigs ++ [
|
||||||
|
secretsConfig
|
||||||
|
];
|
||||||
|
|
||||||
introspectionModule._module.args.cluster = {
|
introspectionModule._module.args.cluster = {
|
||||||
inherit (config) vars;
|
inherit (config) vars;
|
||||||
|
@ -20,7 +31,7 @@ in
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
config.out.injectNixosConfig = hostName: (lib.flatten (lib.mapAttrsToList (_: getHostConfigurations hostName) config.services)) ++ [
|
config.out.injectNixosConfig = hostName: (lib.flatten (lib.mapAttrsToList (getHostConfigurations hostName) config.services)) ++ [
|
||||||
introspectionModule
|
introspectionModule
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue