ansble-terraform-jsonnet/lib/terraform.libsonnet

34 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

2021-10-12 00:13:21 +02:00
local defaults = import "../config/defaults.libsonnet";
2021-08-22 21:22:30 +02:00
{
local rname (server, suffix) = "host_" + server.name + "_" + suffix,
HcloudInstance:: {
name: error "Instance must have field: name",
image: "debian-11",
server_type: error "Instance must have field: server_type",
location: "fsn1"
},
HcloudSSHKey:: {
name: error "Key must have field: name",
2021-10-12 00:13:21 +02:00
public_key: error "Key must have field: public_key"
2021-08-22 21:22:30 +02:00
},
HdnsRecord:: {
zone_id: "${hetznerdns_zone.infra.id}",
name: error "Record must have field: name",
value: error "Record must have field: value",
type: error "Record must have field: type",
2021-10-12 00:13:21 +02:00
ttl: defaults.defaultTTL
2021-08-22 21:22:30 +02:00
},
serverDnsRecords: function (s) {
local attr (s, n) = "${hcloud_server." + s.name + "." + n + "}",
2021-10-12 00:13:21 +02:00
[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" },
2021-08-22 21:22:30 +02:00
}
}