chore: connect terraform to the hive
This way, we can autogenerate records for storage and builders nodes by reading directly the configuration. This makes evaluation of `nix run .#tf` slower, but this makes things more safer and easier, so it's good. Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
parent
349206de12
commit
4ea20c9a96
|
@ -70,6 +70,9 @@
|
||||||
terraform = pkgs.opentofu;
|
terraform = pkgs.opentofu;
|
||||||
terraformCfg = terranix.lib.terranixConfiguration {
|
terraformCfg = terranix.lib.terranixConfiguration {
|
||||||
inherit system;
|
inherit system;
|
||||||
|
extraArgs = {
|
||||||
|
inherit (self) nixosConfigurations;
|
||||||
|
};
|
||||||
modules = [
|
modules = [
|
||||||
./terraform
|
./terraform
|
||||||
{
|
{
|
||||||
|
@ -180,7 +183,7 @@
|
||||||
# Filter all nodes by the range data for this flavor.
|
# Filter all nodes by the range data for this flavor.
|
||||||
filteredNodes = lib.filterAttrs (name: node: lib.any (r: inRange node.bagel.baremetal.num r) ranges) nodes;
|
filteredNodes = lib.filterAttrs (name: node: lib.any (r: inRange node.bagel.baremetal.num r) ranges) nodes;
|
||||||
# The enumeration from baremetal numbers to flavor-specific numbers.
|
# The enumeration from baremetal numbers to flavor-specific numbers.
|
||||||
indexes = lib.traceValSeq (reverseEnumerate (map (n: toString n.bagel.baremetal.num) (builtins.attrValues filteredNodes)));
|
indexes = reverseEnumerate (map (n: toString n.bagel.baremetal.num) (builtins.attrValues filteredNodes));
|
||||||
in
|
in
|
||||||
# Build a new attrset with a new second-level index for the specific flavor.
|
# Build a new attrset with a new second-level index for the specific flavor.
|
||||||
lib.mapAttrs (name: node: setFlavor indexes.${toString node.bagel.baremetal.num} node) filteredNodes;
|
lib.mapAttrs (name: node: setFlavor indexes.${toString node.bagel.baremetal.num} node) filteredNodes;
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
{ lib, config, ... }:
|
{ nixosConfigurations, lib, config, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib) mkEnableOption mkIf tf genList;
|
inherit (lib) mkEnableOption mkIf tf genList filterAttrs;
|
||||||
cfg = config.bagel.dnsimple;
|
cfg = config.bagel.dnsimple;
|
||||||
|
filterBaremetalNodes = submodule: nodes: filterAttrs (name: node: node.config.bagel.baremetal.enable && node.config.bagel.baremetal.${submodule}.enable) nodes;
|
||||||
|
builderNodes = builtins.attrValues (filterBaremetalNodes "builders" nixosConfigurations);
|
||||||
|
storageNodes = builtins.attrValues (filterBaremetalNodes "storage" nixosConfigurations);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.bagel.dnsimple = {
|
options.bagel.dnsimple = {
|
||||||
|
@ -127,7 +130,9 @@ in
|
||||||
(dualProxyRecords "build-coord.wob01.infra" 300 "AAAA" "2a01:584:11::1:11")
|
(dualProxyRecords "build-coord.wob01.infra" 300 "AAAA" "2a01:584:11::1:11")
|
||||||
# TODO: do not hardcode, just reuse the Colmena hive module outputs to generate all the required details.
|
# TODO: do not hardcode, just reuse the Colmena hive module outputs to generate all the required details.
|
||||||
]
|
]
|
||||||
++ (map (index: record "builder-${toString index}.wob01.infra" 300 "AAAA" "2a01:584:11::1:${toString index}") (genList lib.id 11))
|
++ (map (index: record "bm-${toString index}.wob01.infra" 300 "AAAA" "2a01:584:11::1:${toString index}") (genList lib.id 11))
|
||||||
|
++ (map (node: record "builder-${toString node.config.bagel.baremetal.builders.num}.wob01.infra" 300 "CNAME" "bm-${toString node.config.bagel.baremetal.num}") builderNodes)
|
||||||
|
++ (map (node: record "storage-${toString node.config.bagel.baremetal.storage.num}.wob01.infra" 300 "CNAME" "bm-${toString node.config.bagel.baremetal.num}") storageNodes)
|
||||||
++ (
|
++ (
|
||||||
let
|
let
|
||||||
# FIXME: figure out a way to poke `config.services.s3-revproxy` and
|
# FIXME: figure out a way to poke `config.services.s3-revproxy` and
|
||||||
|
|
Loading…
Reference in a new issue