2024-07-07 18:43:05 +00:00
|
|
|
{ lib, config, ... }:
|
|
|
|
let
|
2024-07-09 22:55:42 +00:00
|
|
|
inherit (lib) mkEnableOption mkIf tf genList;
|
2024-07-07 18:43:05 +00:00
|
|
|
cfg = config.bagel.gandi;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.bagel.gandi = {
|
|
|
|
enable = mkEnableOption "the Gandi DNS configuration";
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
terraform.required_providers.gandi = {
|
|
|
|
version = "~> 2.3.0";
|
|
|
|
source = "go-gandi/gandi";
|
|
|
|
};
|
|
|
|
|
|
|
|
resource.secret_resource.gandi_pat.lifecycle.prevent_destroy = true;
|
|
|
|
|
|
|
|
provider.gandi = {
|
|
|
|
personal_access_token = tf.ref "resource.secret_resource.gandi_pat.value";
|
|
|
|
};
|
|
|
|
|
|
|
|
resource.gandi_livedns_domain.forkos_org = {
|
|
|
|
name = "forkos.org";
|
|
|
|
};
|
|
|
|
|
|
|
|
resource.gandi_livedns_record = let
|
|
|
|
record = name: ttl: type: values: {
|
|
|
|
inherit name ttl type values;
|
|
|
|
};
|
|
|
|
|
|
|
|
# TODO: make less fragile and have actual unique and stable names
|
|
|
|
canonicalName = record: let
|
2024-07-08 10:54:15 +00:00
|
|
|
name = builtins.replaceStrings ["." "@"] ["_" "_root_"] record.name;
|
2024-07-07 18:43:05 +00:00
|
|
|
in
|
|
|
|
"forkos_org_${record.type}_${name}";
|
|
|
|
|
|
|
|
forkosRecords = records:
|
|
|
|
builtins.listToAttrs (map (record: {
|
|
|
|
name = canonicalName record;
|
|
|
|
value = record // {
|
|
|
|
zone = tf.ref "resource.gandi_livedns_domain.forkos_org.id";
|
|
|
|
};
|
|
|
|
}) records);
|
|
|
|
|
2024-07-09 22:55:42 +00:00
|
|
|
in forkosRecords ([
|
2024-07-08 10:54:15 +00:00
|
|
|
# (record "@" 3600 "A" ["163.172.69.160"])
|
|
|
|
(record "@" 3600 "AAAA" ["2001:bc8:38ee:100:1000::20"])
|
|
|
|
|
2024-07-07 18:43:05 +00:00
|
|
|
(record "cl" 3600 "A" ["163.172.69.160"])
|
|
|
|
(record "cl" 3600 "AAAA" ["2001:bc8:38ee:100:1000::10"])
|
|
|
|
|
|
|
|
(record "fodwatch" 3600 "A" ["163.172.69.160"])
|
|
|
|
(record "fodwatch" 3600 "AAAA" ["2001:bc8:38ee:100:1000::30"])
|
|
|
|
|
|
|
|
(record "netbox" 3600 "A" ["163.172.69.160"])
|
|
|
|
(record "netbox" 3600 "AAAA" ["2001:bc8:38ee:100:1000::20"])
|
|
|
|
|
2024-07-07 21:48:23 +00:00
|
|
|
(record "bagel-box.infra" 3600 "AAAA" ["2001:bc8:38ee:100:100::1"])
|
2024-07-07 18:43:05 +00:00
|
|
|
(record "gerrit01.infra" 3600 "AAAA" ["2001:bc8:38ee:100:1000::10"])
|
|
|
|
(record "fodwatch.infra" 3600 "AAAA" ["2001:bc8:38ee:100:1000::30"])
|
|
|
|
(record "meta01.infra" 3600 "AAAA" ["2001:bc8:38ee:100:1000::20"])
|
|
|
|
|
2024-07-08 21:55:11 +00:00
|
|
|
(record "amqp" 3600 "CNAME" ["bagel-box.infra"])
|
2024-07-08 10:54:15 +00:00
|
|
|
(record "grafana" 3600 "CNAME" ["meta01.infra"])
|
2024-07-08 21:55:11 +00:00
|
|
|
(record "hydra" 3600 "CNAME" ["bagel-box.infra"])
|
2024-07-07 18:43:05 +00:00
|
|
|
(record "loki" 3600 "CNAME" ["meta01.infra"])
|
2024-07-08 10:54:15 +00:00
|
|
|
(record "mimir" 3600 "CNAME" ["meta01.infra"])
|
|
|
|
(record "matrix" 3600 "CNAME" ["meta01.infra"])
|
2024-07-09 22:55:42 +00:00
|
|
|
|
|
|
|
(record "vpn-gw.wob01.infra" 3600 "AAAA" [ "2a01:584:11::2" ])
|
|
|
|
# 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" 3600 "AAAA" [ "2a01:584:11::1:${toString index}" ]) (genList lib.id 12));
|
2024-07-07 18:43:05 +00:00
|
|
|
};
|
|
|
|
}
|