feat(wordpress/module): Factorize ip construction
All checks were successful
build configuration / build_storage01 (push) Successful in 48s
build configuration / build_web01 (push) Successful in 56s
build configuration / build_compute01 (push) Successful in 1m9s

This commit is contained in:
Tom Hubrecht 2024-01-08 17:59:22 +01:00
parent bdc23df66c
commit 9c457666f5

View file

@ -9,6 +9,7 @@ let
cfg = config.services.wp-containers; cfg = config.services.wp-containers;
mkName = builtins.replaceStrings [ "." ] [ "-" ]; mkName = builtins.replaceStrings [ "." ] [ "-" ];
mkIp = ip: i: "${ip}.${builtins.toString i}";
mkConfig = { name, value, i }: { mkConfig = { name, value, i }: {
services.wordpress = { services.wordpress = {
@ -25,7 +26,7 @@ let
networking = { networking = {
hostName = mkName name; hostName = mkName name;
hosts."10.0.0.${builtins.toString i}" = [ name ]; hosts.${mkIp "10.0.0" i} = [ name ];
firewall.allowedTCPPorts = [ 443 ]; firewall.allowedTCPPorts = [ 443 ];
}; };
@ -51,8 +52,8 @@ let
mountPoint = certs.${site.name}.directory; mountPoint = certs.${site.name}.directory;
}; };
hostAddress = "10.31.41.${builtins.toString i}"; hostAddress = mkIp "10.31.41" i;
localAddress = "10.0.0.${builtins.toString i}"; localAddress = mkIp "10.0.0" i;
autoStart = true; autoStart = true;
@ -66,9 +67,8 @@ let
enableACME = true; enableACME = true;
forceSSL = true; forceSSL = true;
locations."/".proxyPass = "https://10.31.41.${builtins.toString i}:${ locations."/".proxyPass =
builtins.toString (cfg.basePort + i) "https://${mkIp "10.31.41" i}:${builtins.toString (cfg.basePort + i)}";
}";
}; };
}; };