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

@ -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;
};
};
};
}