From f8c584669237a94b96c64a62b145d4e71bbff1ad Mon Sep 17 00:00:00 2001 From: Romain Paquet Date: Sat, 19 Jul 2025 18:48:09 +0200 Subject: [PATCH] use a template for turifer.dev zone file --- infra/.terraform.lock.hcl | 17 +++++++++++++++++ infra/crocus.tf | 12 ++++++++++++ infra/dns.tf | 10 +++++++++- infra/{ => templates}/turifer.dev.zone | 4 ++-- machines/flake-module.nix | 2 +- 5 files changed, 41 insertions(+), 4 deletions(-) rename infra/{ => templates}/turifer.dev.zone (90%) diff --git a/infra/.terraform.lock.hcl b/infra/.terraform.lock.hcl index 2ef5f5a..43613ee 100644 --- a/infra/.terraform.lock.hcl +++ b/infra/.terraform.lock.hcl @@ -21,6 +21,23 @@ provider "registry.opentofu.org/go-gandi/gandi" { ] } +provider "registry.opentofu.org/hashicorp/local" { + version = "2.5.3" + hashes = [ + "h1:mC9+u1eaUILTjxey6Ivyf/3djm//RNNze9kBVX/trng=", + "zh:32e1d4b0595cea6cda4ca256195c162772ddff25594ab4008731a2ec7be230bf", + "zh:48c390af0c87df994ec9796f04ec2582bcac581fb81ed6bb58e0671da1c17991", + "zh:4be7289c969218a57b40902e2f359914f8d35a7f97b439140cb711aa21e494bd", + "zh:4cf958e631e99ed6c8b522c9b22e1f1b568c0bdadb01dd002ca7dffb1c927764", + "zh:7a0132c0faca4c4c96aa70808effd6817e28712bf5a39881666ac377b4250acf", + "zh:7d60de08fac427fb045e4590d1b921b6778498eee9eb16f78c64d4c577bde096", + "zh:91003bee5981e99ec3925ce2f452a5f743827f9d0e131a86613549c1464796f0", + "zh:9fe2fe75977c8149e2515fb30c6cc6cfd57b225d4ce592c570d81a3831d7ffa3", + "zh:e210e6be54933ce93e03d0994e520ba289aa01b2c1f70e77afb8f2ee796b0fe3", + "zh:e8793e5f9422f2b31a804e51806595f335b827c9a38db18766960464566f21d5", + ] +} + provider "registry.opentofu.org/hetznercloud/hcloud" { version = "1.51.0" constraints = "~> 1.45" diff --git a/infra/crocus.tf b/infra/crocus.tf index abd9bf8..ccda070 100644 --- a/infra/crocus.tf +++ b/infra/crocus.tf @@ -1,8 +1,20 @@ resource "hcloud_server" "crocus_server" { name = "crocus" server_type = "cx22" + datacenter = "nbg1-dc3" image = "ubuntu-20.04" firewall_ids = [hcloud_firewall.crocus_firewall.id] + public_net { + ipv4 = hcloud_primary_ip.crocus_ipv4.id + } +} + +resource "hcloud_primary_ip" "crocus_ipv4" { + name = "crocus_ipv4" + type = "ipv4" + datacenter = "nbg1-dc3" + assignee_type = "server" + auto_delete = true } resource "hcloud_firewall" "crocus_firewall" { diff --git a/infra/dns.tf b/infra/dns.tf index 3dc6b1a..d028a5e 100644 --- a/infra/dns.tf +++ b/infra/dns.tf @@ -28,5 +28,13 @@ data "ovh_domain_zone" "turifer_dev" { resource "ovh_domain_zone_import" "turifer_dev_import" { zone_name = "turifer.dev" - zone_file = file("./turifer.dev.zone") + zone_file = local.turifer_dev_zone_file } + +locals { + turifer_dev_zone_file = templatefile("./templates/turifer.dev.zone", { + crocus_ipv4_address = hcloud_server.crocus_server.ipv4_address + crocus_ipv6_address = hcloud_server.crocus_server.ipv6_address + }) +} + diff --git a/infra/turifer.dev.zone b/infra/templates/turifer.dev.zone similarity index 90% rename from infra/turifer.dev.zone rename to infra/templates/turifer.dev.zone index 61b4d64..a94a640 100644 --- a/infra/turifer.dev.zone +++ b/infra/templates/turifer.dev.zone @@ -17,5 +17,5 @@ _submissions._tcp.turifer.dev. 3000 IN SRV 0 1 465 smtp.migadu.com. _imaps._tcp.turifer.dev. 3000 IN SRV 0 1 993 imap.migadu.com. _pop3s._tcp.turifer.dev. 3000 IN SRV 0 1 995 pop.migadu.com. -git.turifer.dev. 10800 IN A 167.235.28.141 -git.turifer.dev. 10800 IN AAAA 2a01:4f8:1c1e:e415::1 +git.turifer.dev. 10800 IN A ${crocus_ipv4_address} +git.turifer.dev. 10800 IN AAAA ${crocus_ipv6_address} diff --git a/machines/flake-module.nix b/machines/flake-module.nix index 6e8dfff..7d46d50 100644 --- a/machines/flake-module.nix +++ b/machines/flake-module.nix @@ -39,7 +39,7 @@ roles.moon.machines.crocus = { settings = { stableEndpoints = [ - "167.235.28.141" + "116.203.18.122" "2a01:4f8:1c1e:e415::/64" ]; };