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;
|
|
|
|
|
};
|
|
|
|
|
|
2024-07-14 17:46:38 +00:00
|
|
|
|
proxyRecords = name: ttl: type: values: [
|
|
|
|
|
# kurisu.lahfa.xyz running a sniproxy:
|
|
|
|
|
(record name ttl "A" ["163.172.69.160"])
|
|
|
|
|
(record name ttl type values)
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
# Creates a extra *.p record pointing to the sniproxy
|
|
|
|
|
dualProxyRecords = name: ttl: type: values: lib.flatten [
|
|
|
|
|
(record name ttl type values)
|
|
|
|
|
(proxyRecords "${name}.p" ttl type values)
|
|
|
|
|
];
|
|
|
|
|
|
2024-07-07 18:43:05 +00:00
|
|
|
|
# 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";
|
|
|
|
|
};
|
2024-07-14 17:46:38 +00:00
|
|
|
|
}) (lib.flatten records));
|
2024-07-07 18:43:05 +00:00
|
|
|
|
|
2024-07-09 22:55:42 +00:00
|
|
|
|
in forkosRecords ([
|
2024-08-16 06:51:31 +00:00
|
|
|
|
# (record "@" 300 "A" ["163.172.69.160"])
|
|
|
|
|
(record "@" 300 "AAAA" ["2001:bc8:38ee:100:1000::20"])
|
2024-07-08 10:54:15 +00:00
|
|
|
|
|
2024-08-16 06:51:31 +00:00
|
|
|
|
(dualProxyRecords "bagel-box.infra" 300 "AAAA" ["2001:bc8:38ee:100:100::1"])
|
|
|
|
|
(dualProxyRecords "gerrit01.infra" 300 "AAAA" ["2001:bc8:38ee:100:1000::10"])
|
|
|
|
|
(dualProxyRecords "meta01.infra" 300 "AAAA" ["2001:bc8:38ee:100:1000::20"])
|
|
|
|
|
(dualProxyRecords "fodwatch.infra" 300 "AAAA" ["2001:bc8:38ee:100:1000::30"])
|
2024-07-17 12:41:38 +00:00
|
|
|
|
# git.infra.forkos.org exposes opensshd
|
2024-08-16 06:51:31 +00:00
|
|
|
|
(dualProxyRecords "git.infra" 300 "AAAA" ["2001:bc8:38ee:100:1000::41"])
|
2024-07-17 12:41:38 +00:00
|
|
|
|
# git.p.forkos.org exposes forgejo ssh server.
|
2024-08-16 06:51:31 +00:00
|
|
|
|
(proxyRecords "git.p" 300 "AAAA" ["2001:bc8:38ee:100:1000::40"])
|
|
|
|
|
(dualProxyRecords "buildbot.infra" 300 "AAAA" ["2001:bc8:38ee:100:1000::50"])
|
|
|
|
|
(dualProxyRecords "public01.infra" 300 "AAAA" ["2001:bc8:38ee:100:1000::60"])
|
2024-07-07 18:43:05 +00:00
|
|
|
|
|
2024-08-16 06:51:31 +00:00
|
|
|
|
(record "cl" 300 "CNAME" ["gerrit01.infra.p"])
|
|
|
|
|
(record "fodwatch" 300 "CNAME" ["fodwatch.infra.p"])
|
2024-07-17 12:41:38 +00:00
|
|
|
|
# git.p.forkos.org is the proxy variant of the Forgejo server.
|
2024-08-16 06:51:31 +00:00
|
|
|
|
(record "git" 300 "CNAME" ["git.p"])
|
|
|
|
|
(record "netbox" 300 "CNAME" ["meta01.infra.p"])
|
|
|
|
|
(record "amqp" 300 "CNAME" ["bagel-box.infra.p"])
|
|
|
|
|
(record "grafana" 300 "CNAME" ["meta01.infra.p"])
|
|
|
|
|
(record "hydra" 300 "CNAME" ["build-coord.wob01.infra.p"])
|
|
|
|
|
(record "loki" 300 "CNAME" ["meta01.infra.p"])
|
|
|
|
|
(record "mimir" 300 "CNAME" ["meta01.infra.p"])
|
2024-08-23 19:03:07 +00:00
|
|
|
|
(record "pyroscope" 300 "CNAME" ["meta01.infra.p"])
|
2024-08-31 12:05:30 +00:00
|
|
|
|
(record "tempo" 300 "CNAME" ["meta01.infra.p"])
|
2024-08-16 06:51:31 +00:00
|
|
|
|
(record "matrix" 300 "CNAME" ["meta01.infra.p"])
|
|
|
|
|
(record "alerts" 300 "CNAME" ["meta01.infra.p"])
|
|
|
|
|
(record "buildbot" 300 "CNAME" ["buildbot.infra.p"])
|
|
|
|
|
(record "b" 300 "CNAME" ["public01.infra.p"])
|
|
|
|
|
(record "postgres" 300 "CNAME" ["bagel-box.infra.p"])
|
2024-08-21 14:27:00 +00:00
|
|
|
|
(record "news" 3600 "CNAME" ["public01.infra.p"])
|
2024-07-09 22:55:42 +00:00
|
|
|
|
|
2024-07-23 15:22:45 +00:00
|
|
|
|
# S3 in delroth's basement
|
2024-08-19 21:06:46 +00:00
|
|
|
|
(record "cache" 300 "AAAA" ["2a02:168:6426::12"]) # smol.delroth.net
|
|
|
|
|
(record "cache" 300 "A" ["195.39.247.161"]) # sni proxy
|
2024-07-23 15:22:45 +00:00
|
|
|
|
|
2024-08-16 06:51:31 +00:00
|
|
|
|
(record "vpn-gw.wob01.infra" 300 "AAAA" [ "2a01:584:11::2" ])
|
2024-08-13 17:12:36 +00:00
|
|
|
|
|
2024-08-16 06:51:31 +00:00
|
|
|
|
(dualProxyRecords "build-coord.wob01.infra" 300 "AAAA" [ "2a01:584:11::1:11" ])
|
2024-07-09 22:55:42 +00:00
|
|
|
|
# TODO: do not hardcode, just reuse the Colmena hive module outputs to generate all the required details.
|
2024-08-30 22:19:40 +00:00
|
|
|
|
]
|
|
|
|
|
++ (map (index: record "builder-${toString index}.wob01.infra" 300 "AAAA" [ "2a01:584:11::1:${toString index}" ]) (genList lib.id 11))
|
|
|
|
|
++ (
|
|
|
|
|
let
|
|
|
|
|
# FIXME: figure out a way to poke `config.services.s3-revproxy` and
|
|
|
|
|
# automate the DNS part away?
|
|
|
|
|
buckets = [
|
|
|
|
|
"channels"
|
|
|
|
|
"releases"
|
|
|
|
|
"channel-scripts-test"
|
|
|
|
|
];
|
|
|
|
|
in
|
|
|
|
|
map (bucket: record "${bucket}" 300 "CNAME" [ "public01.infra.p" ]) buckets
|
|
|
|
|
));
|
2024-07-07 18:43:05 +00:00
|
|
|
|
};
|
|
|
|
|
}
|