Finish cleaning up terraform nomenclature for DNS and so on

This commit is contained in:
kat witch 2021-08-08 23:04:17 +01:00
parent 81d5278809
commit a452692daf
No known key found for this signature in database
GPG key ID: 1B477797DCA5EC72
8 changed files with 32 additions and 109 deletions

View file

@ -23,92 +23,3 @@ config = {
};
};
}
# For the eventual migration
#resources.athame = {
#provider = "hcloud";
# type = "server";
# inputs = {
# name = "athame";
# image = "ubuntu-20.04";
# server_type = "cpx21";
# location = "nbg1";
# backups = false;
# ssh_keys = [ (hcloud_ssh_key.refAttr "id") ];
# };
# connection = { host = config.lib.tf.terraformSelf "ipv4_address"; };
# provisioners = [
# {
# file = {
# destination = "/tmp/sshportfix.nix";
# content = "{ config, ...}: { services.openssh.ports = [ 62954 ]; }";
# };
# }
# {
# remote-exec.command =
# "curl https://raw.githubusercontent.com/elitak/nixos-infect/master/nixos-infect | NIXOS_IMPORT=/tmp/sshportfix.nix NO_REBOOT=true PROVIDER=hetznercloud NIX_CHANNEL=nixos-20.09 bash 2>&1 | tee /tmp/infect.log";
# }
# {
# remote-exec.command = "reboot";
# onFailure = "continue";
# }
# ];
#};
/* resources.athame_rdns = {
provider = "hcloud";
type = "rdns";
inputs = {
server_id = athame.refAttr "id";
dns_ptr = "athame.kittywit.ch";
ip_address = athame.refAttr "ipv4_address";
};
};
*/
#dns.records.kittywitch_athame = {
# tld = "kittywit.ch.";
# domain = "athame";
# a.address = athame.refAttr "ipv4_address";
#};
#dns.records.kittywitch_root = {
# tld = "kittywit.ch.";
# domain = "@";
# a.address = athame.refAttr "ipv4_address";
#};
#dns.records.kittywitch_athame_v6 = {
# tld = "kittywit.ch.";
# domain = "athame";
# aaaa.address = athame.refAttr "ipv6_address";
#};
#dns.records.kittywitch_root_v6 = {
# tld = "kittywit.ch.";
# domain = "@";
# aaaa.address = athame.refAttr "ipv6_address";
#};
#dns.records.kittywitch_www = {
# tld = "kittywit.ch.";
# domain = "www";
# cname.target = "athame.kittywit.ch.";
#};
# connection = {
# host = athame.refAttr "ipv4_address";
# port = 62954;
# };
#triggers.switch = lib.mapAttrs (name: record:
# {
# A = config.lib.tf.terraformExpr
# ''join(",", ${record.out.resource.namedRef}.addresses)'';
# AAAA = config.lib.tf.terraformExpr
# ''join(",", ${record.out.resource.namedRef}.addresses)'';
# CNAME = record.out.resource.refAttr "cname";
# SRV = record.out.resource.refAttr "id";
# }.${record.out.type}) config.dns.records;

View file

@ -85,12 +85,7 @@ with lib;
kw.dns.ipv4 = "168.119.126.111";
kw.dns.ipv6 = (lib.head config.networking.interfaces.enp1s0.ipv6.addresses).address;
deploy.tf.dns.records.kittywitch_athame_v6 = {
tld = "kittywit.ch.";
domain = "athame";
aaaa.address = config.kw.dns.ipv6;
};
kw.dns.isPublic = true;
# Yggdrasil

View file

@ -25,6 +25,7 @@ with lib;
type = types.nullOr types.str;
default = "";
};
isPublic = mkEnableOption "Provide DNS for the public primary IP addresses of the host";
ipv4 = mkOption {
type = types.str;
};

View file

@ -25,11 +25,14 @@ with lib;
type = types.nullOr types.str;
default = "";
};
isPublic = mkEnableOption "Provide DNS for the public primary IP addresses of the host";
ipv4 = mkOption {
type = types.str;
type = types.nullOr types.str;
default = null;
};
ipv6 = mkOption {
type = types.str;
type = types.nullOr types.str;
default = null;
};
};
@ -43,7 +46,20 @@ with lib;
kw.dns.ipv4 = mkDefault (mkIf (tf.resources ? config.networking.hostName) (mkOptionDefault (config.deploy.tf.resources."${config.networking.hostName}".refAttr "ipv4_address")));
kw.dns.ipv6 = mkDefault (mkIf (tf.resources ? config.networking.hostName) (mkOptionDefault (config.deploy.tf.resources."${config.networking.hostName}".refAttr "ipv6_address")));
# This is derived.
# These are derived.
kw.dns.domain = builtins.substring 0 ((builtins.stringLength config.kw.dns.tld) - 1) config.kw.dns.tld;
deploy.tf.dns.records = lib.mkIf (config.kw.dns.isPublic) {
"node_${config.networking.hostName}_v4" = {
tld = config.kw.dns.tld;
domain = config.networking.hostName;
a.address = config.kw.dns.ipv4;
};
"node_${config.networking.hostName}_v6" = {
tld = config.kw.dns.tld;
domain = config.networking.hostName;
aaaa.address = config.kw.dns.ipv6;
};
};
};
}

View file

@ -9,9 +9,9 @@
};
};
deploy.tf.dns.records.kittywitch_files = {
tld = "kittywit.ch.";
deploy.tf.dns.records.services_filehost = {
tld = config.kw.dns.tld;
domain = "files";
cname.target = "athame.kittywit.ch.";
cname.target = "${config.networking.hostName}.${config.kw.dns.tld}";
};
}

View file

@ -28,7 +28,7 @@
locations = { "/".proxyPass = "http://127.0.0.1:3001"; };
};
deploy.tf.dns.records.kittywitch_graph = {
deploy.tf.dns.records.services_grafana = {
tld = config.kw.dns.tld;
domain = "graph";
cname.target = "${config.networking.hostName}.${config.kw.dns.tld}";

View file

@ -4,15 +4,15 @@
deploy.targets.personal = {
nodeNames = [ "samhain" "yule"];
tf = { config, ... }: {
dns.records.kittywitch_net_grimoire = {
tld = "kittywit.ch.";
domain = "grimoire.net";
dns.records.ygg_grimoire = {
tld = config.kw.dns.tld;
domain = "grimoire.${config.kw.dns.ygg_prefix}";
aaaa.address = "200:c87d:7960:916:bf0e:a0e1:3da7:4fc6";
};
dns.records.kittywitch_net_boline = {
tld = "kittywit.ch.";
domain = "boline.net";
dns.records.ygg_boline = {
tld = config.kw.dns.tld;
domain = "boline.${config.kw.dns.ygg_prefix}";
aaaa.address = "200:474d:14f7:1d21:f171:4e85:a3fa:9393";
};
};

2
wiki

@ -1 +1 @@
Subproject commit bbc1c86ceb851b413cd8bcb414fd56a39fc2de87
Subproject commit cda4f1d9cb996f528ad5d2395abef1d6ed6bbc46