1
1
Fork 0
mirror of https://gitlab.archlinux.org/archlinux/infrastructure.git synced 2024-05-26 17:46:10 +02:00

improve terraform handling of virtual machine domains

machine.domain has been an mandatory attribute which creates
<domain>.archlinux.org entries automagically. For migrations this can be
a problem if <domain>.archlinux.org supposed to point to a different
machine. Adding the new machine with the same domain leads to additional
DNS entries. The DNS ends up pointing to both machines in this case.
By making the domain attribute optional for machines, we allow the new
machines to be created without any domain pointing to them.
This commit is contained in:
Frederik Schwan 2021-01-24 16:18:19 +01:00
parent d23d14ca2d
commit 38dc229288
No known key found for this signature in database
GPG Key ID: 9D4C5AA15426DA0A
2 changed files with 7 additions and 4 deletions

View File

@ -36,7 +36,7 @@ locals {
#
# Valid parameters are:
# - server_type (mandatory)
# - domain (mandatory)
# - domain (optional, creates dns entry <domain>.archlinux.org pointing to the machine)
# - ttl (optional, applies to the dns entries)
# - zone (optionel, required for pkgbuild.com machines)
#
@ -81,7 +81,6 @@ locals {
}
"lists.archlinux.org" = {
server_type = "cx11"
domain = "lists"
}
"mail.archlinux.org" = {
server_type = "cx11"

View File

@ -116,7 +116,9 @@ resource "hcloud_server" "machine" {
}
resource "hetznerdns_record" "machine_a" {
for_each = local.machines
for_each = {
for name, machine in local.machines : name => machine if can(machine.domain)
}
zone_id = lookup(local.machines[each.key], "zone", hetznerdns_zone.archlinux.id)
name = each.value.domain
@ -126,7 +128,9 @@ resource "hetznerdns_record" "machine_a" {
}
resource "hetznerdns_record" "machine_aaaa" {
for_each = local.machines
for_each = {
for name, machine in local.machines : name => machine if can(machine.domain)
}
zone_id = lookup(local.machines[each.key], "zone", hetznerdns_zone.archlinux.id)
name = each.value.domain