Refactor and add deployment support

This commit is contained in:
2021-10-12 00:13:21 +02:00
parent ae2e359225
commit 6cc0596b72
13 changed files with 218 additions and 106 deletions

View File

@@ -1,7 +1,6 @@
local config = import "../config/config.libsonnet";
local defaults = import "../config/defaults.libsonnet";
{
local terraform = self,
local rname (server, suffix) = "host_" + server.name + "_" + suffix,
HcloudInstance:: {
@@ -13,8 +12,7 @@ local config = import "../config/config.libsonnet";
HcloudSSHKey:: {
name: error "Key must have field: name",
public_key: error "Key must have field: public_key",
labels: { source: "terraform" }
public_key: error "Key must have field: public_key"
},
HdnsRecord:: {
@@ -22,14 +20,14 @@ local config = import "../config/config.libsonnet";
name: error "Record must have field: name",
value: error "Record must have field: value",
type: error "Record must have field: type",
ttl: config.defaultTTL
ttl: defaults.defaultTTL
},
serverDnsRecords: function (s) {
local attr (s, n) = "${hcloud_server." + s.name + "." + n + "}",
[rname(s, "A")]: terraform.HdnsRecord{ name: s.publicSubdomain, value: attr(s, "ipv4_address"), type: "A" },
[rname(s, "AAAA")]: terraform.HdnsRecord{ name: s.publicSubdomain, value: attr(s, "ipv6_address"), type: "AAAA" },
[rname(s, "VPN")]: terraform.HdnsRecord{ name: s.internalSubdomain, value: s.wireguardIp, type: "AAAA" },
[rname(s, "A")]: $.HdnsRecord{ name: s.networking.publicSubdomain, value: attr(s, "ipv4_address"), type: "A" },
[rname(s, "AAAA")]: $.HdnsRecord{ name: s.networking.publicSubdomain, value: attr(s, "ipv6_address"), type: "AAAA" },
[rname(s, "VPN")]: $.HdnsRecord{ name: s.networking.internalSubdomain, value: s.networking.wireguardIp, type: "AAAA" },
}
}