From 6fadc45e24846941b1786d6057903bf7da43e402 Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Tue, 29 Oct 2024 14:10:54 +0100 Subject: [PATCH] Improve dnsconfig a bit --- Makefile | 7 +++++-- dns/functions.js | 16 ++++++++++++---- dnsconfig.js | 3 --- ...ol.yml => create-services-for-dnscontrol.yml} | 0 services.auto.tfvars | 3 +++ 5 files changed, 20 insertions(+), 9 deletions(-) rename playbooks/{create_services_for_dnscontrol.yml => create-services-for-dnscontrol.yml} (100%) diff --git a/Makefile b/Makefile index ef933f7..8c6c61a 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ PWD := $(shell pwd) ./dns/services.json: ./inventory/group_vars/all/all_services.yml ansible-playbook \ -e services_json_file=$(PWD)/dns/services.json \ - playbooks/create_services_for_dnscontrol.yml + playbooks/create-services-for-dnscontrol.yml ./dns/dkim-ses.json: .FORCE tofu output --json aws_ses_dkim \ @@ -50,9 +50,12 @@ dns: output-dns dns-check: output-dns dnscontrol check-creds ovh -all: +tofu-dns: $(MAKE) tofu $(MAKE) dns + +all: + $(MAKE) tofu-dns @printf "\n=====\n\n" ansible-playbook ./playbooks/stop-and-backup-unused.yml -t $(TAGS) ansible-playbook ./playbooks/serguzim.net.yml -t $(TAGS) diff --git a/dns/functions.js b/dns/functions.js index 8d9f906..c97376e 100644 --- a/dns/functions.js +++ b/dns/functions.js @@ -28,10 +28,18 @@ function collect_services(domain) { } function my_host_record(target, host) { - return [ - A(target, host.ipv4_address), - AAAA(target, host.ipv6_address) - ]; + switch (target) { + case "db": + return [ + A(target, host.ipv4_address_vpn), + AAAA(target, host.ipv6_address_vpn) + ]; + default: + return [ + A(target, host.ipv4_address), + AAAA(target, host.ipv6_address) + ]; + } } function verify_amazon_ses(dkims) { diff --git a/dnsconfig.js b/dnsconfig.js index e28c2a5..5515545 100644 --- a/dnsconfig.js +++ b/dnsconfig.js @@ -81,10 +81,7 @@ D("serguzim.me", REG_OVH, DnsProvider(DSP_OVH), NS("acme", services["acme_dns"].resolve_host().fqdn + "."), - CNAME("db", "node002.vpn.serguzim.net."), - // Other records - A("loetlabor", "141.23.124.187"), A("ls", "62.141.37.39"), A("test", "62.141.37.39"), CNAME("cloud", "nx45221.your-storageshare.de.") diff --git a/playbooks/create_services_for_dnscontrol.yml b/playbooks/create-services-for-dnscontrol.yml similarity index 100% rename from playbooks/create_services_for_dnscontrol.yml rename to playbooks/create-services-for-dnscontrol.yml diff --git a/services.auto.tfvars b/services.auto.tfvars index ac3252d..34a76ed 100644 --- a/services.auto.tfvars +++ b/services.auto.tfvars @@ -336,6 +336,9 @@ services = { "postgresql" = { host = "node002" + dns = [{ + domain = "db.serguzim.me" + }] backup = [{ name = "postgresql" type = "hook"