From b02fa230ec0a3340c5f3654275fbe97f1cc2e4dc Mon Sep 17 00:00:00 2001 From: Otho Date: Sat, 24 Feb 2024 00:35:11 -0500 Subject: [PATCH] Updates to dns management. Add .env.dit and .htaccess. --- .env.dist | 1 + .htaccess | 1 + Taskfile.yaml | 13 +++++++++++-- dns.tf | 45 ++++++++++++++++++--------------------------- 4 files changed, 31 insertions(+), 29 deletions(-) create mode 120000 .env.dist create mode 100644 .htaccess diff --git a/.env.dist b/.env.dist new file mode 120000 index 0000000..4e779e1 --- /dev/null +++ b/.env.dist @@ -0,0 +1 @@ +../.env.dist \ No newline at end of file diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..a7a56f7 --- /dev/null +++ b/.htaccess @@ -0,0 +1 @@ +Require all denied \ No newline at end of file diff --git a/Taskfile.yaml b/Taskfile.yaml index 7e512f4..19f90e5 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -82,10 +82,19 @@ tasks: vars: remote_path: "{{.ITEM}}" - plan: source .env; terraform init; terraform plan - migrate-state: terraform init -migrate-state + # Terraform + plan: + - task: tf + vars: + CLI_ARGS: plan + apply: + - task: tf + vars: + CLI_ARGS: apply + tf: source .env; terraform init; terraform {{.CLI_ARGS}} # Utilities + printenv: source .env; printenv path-update: echo scp "{{.local_path}}" "$stashbox_domain:{{.remote_path}}" path-backup: scp "$stashbox_domain:{{.remote_path}}" "./.$(basename {{.remote_path}})-$(date +%s)" || echo "No file found." path-diff: diff --git a/dns.tf b/dns.tf index 4e279fd..1558bd0 100644 --- a/dns.tf +++ b/dns.tf @@ -10,71 +10,62 @@ terraform { provider "namecheap" {} -variable "stash_domain" { +variable "stashbox_domain" { type = string default = "web.stash" } -variable "web_addr" { +variable "stashbox_web_addr" { type = string default = "::db" } -variable "feed_addr" { +variable "stashbox_feed_addr" { type = string default = "::feed" } -variable "app_addr" { - type = string - default = "::beef" -} - -variable "ip4_ext" { +variable "stashbox_ip4_ext" { type = string default = "0.0.0.0" } -resource "namecheap_domain_records" "stash" { - domain = var.stash_domain +resource "namecheap_domain_records" "stashbox" { + domain = var.stashbox_domain record { hostname = "www" - address = var.web_addr + address = var.stashbox_web_addr type = "AAAA" + ttl = 1799 } record { hostname = "www" - address = var.ip4_ext + address = var.stashbox_ip4_ext type = "A" + ttl = 1799 } record { hostname = "feed" - address = var.feed_addr + address = var.stashbox_feed_addr type = "AAAA" + ttl = 1799 } record { hostname = "feed" - address = var.ip4_ext - type = "A" - } - record { - hostname = "app" - address = var.app_addr - type = "AAAA" - } - record { - hostname = "app" - address = var.ip4_ext + address = var.stashbox_ip4_ext type = "A" + ttl = 1799 } record { hostname = "@" - address = "www.${var.stash_domain}" + address = "www.${var.stashbox_domain}." type = "CNAME" + ttl = 1799 } record { hostname = "plex" - address = "feed.${var.stash_domain}" + address = "feed.${var.stashbox_domain}." type = "CNAME" + ttl = 1799 } }