Refactor "dns" to remove target-domain split
This commit is contained in:
parent
82c25edf8e
commit
810bf9acb5
8 changed files with 33 additions and 72 deletions
|
@ -16,7 +16,6 @@ variable "services" {
|
||||||
host = string
|
host = string
|
||||||
dns = optional(list(object({
|
dns = optional(list(object({
|
||||||
domain = string
|
domain = string
|
||||||
target = string
|
|
||||||
name = optional(string)
|
name = optional(string)
|
||||||
alias = optional(string)
|
alias = optional(string)
|
||||||
})))
|
})))
|
||||||
|
|
|
@ -70,6 +70,6 @@ resource "authentik_provider_oauth2" "service_providers" {
|
||||||
resource "authentik_application" "service_applications" {
|
resource "authentik_application" "service_applications" {
|
||||||
for_each = local.services_auth
|
for_each = local.services_auth
|
||||||
name = each.value.name
|
name = each.value.name
|
||||||
slug = "${each.value.dns[0].target}-serguzim-me"
|
slug = replace(each.value.dns[0].domain, ".", "-")
|
||||||
protocol_provider = authentik_provider_oauth2.service_providers[each.key].id
|
protocol_provider = authentik_provider_oauth2.service_providers[each.key].id
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ variable "services" {
|
||||||
host = string
|
host = string
|
||||||
dns = optional(list(object({
|
dns = optional(list(object({
|
||||||
domain = string
|
domain = string
|
||||||
target = string
|
|
||||||
name = optional(string)
|
name = optional(string)
|
||||||
alias = optional(string)
|
alias = optional(string)
|
||||||
})))
|
})))
|
||||||
|
|
|
@ -53,11 +53,7 @@ class FilterModule(object):
|
||||||
for service in services:
|
for service in services:
|
||||||
if mon := service.get("monitoring"):
|
if mon := service.get("monitoring"):
|
||||||
if service.get("dns"):
|
if service.get("dns"):
|
||||||
dns = service["dns"][0]
|
url = f"https://{service["dns"][0]['domain']}"
|
||||||
url = "https://"
|
|
||||||
if dns.get("target") != "@":
|
|
||||||
url += f"{dns["target"]}."
|
|
||||||
url += dns['domain']
|
|
||||||
|
|
||||||
if mon_url := mon.get("url"):
|
if mon_url := mon.get("url"):
|
||||||
if mon_url.startswith("/"):
|
if mon_url.startswith("/"):
|
||||||
|
|
|
@ -38,9 +38,11 @@ class FilterModule(object):
|
||||||
for service in services:
|
for service in services:
|
||||||
for dns in service.get("dns") or []:
|
for dns in service.get("dns") or []:
|
||||||
name = dns.get("name") or service["name"]
|
name = dns.get("name") or service["name"]
|
||||||
|
domain_parts = dns["domain"].split(".")
|
||||||
|
target_parts = domain_parts[:-2] or ["@"]
|
||||||
result[name] = {
|
result[name] = {
|
||||||
"target": dns["target"],
|
"target": ".".join(target_parts),
|
||||||
"domain": dns["domain"],
|
"domain": ".".join(domain_parts[-2:]),
|
||||||
}
|
}
|
||||||
|
|
||||||
if dns.get("alias"):
|
if dns.get("alias"):
|
||||||
|
|
|
@ -3,8 +3,7 @@ services = {
|
||||||
name = "acme_dns"
|
name = "acme_dns"
|
||||||
host = "node001"
|
host = "node001"
|
||||||
dns = [{
|
dns = [{
|
||||||
domain = "serguzim.me"
|
domain = "acme.serguzim.me"
|
||||||
target = "acme"
|
|
||||||
}]
|
}]
|
||||||
monitoring = {
|
monitoring = {
|
||||||
url = "/health"
|
url = "/health"
|
||||||
|
@ -19,8 +18,7 @@ services = {
|
||||||
name = "authentik"
|
name = "authentik"
|
||||||
host = "node003"
|
host = "node003"
|
||||||
dns = [{
|
dns = [{
|
||||||
domain = "serguzim.me"
|
domain = "auth.serguzim.me"
|
||||||
target = "auth"
|
|
||||||
}]
|
}]
|
||||||
monitoring = {
|
monitoring = {
|
||||||
url = "/-/health/live/"
|
url = "/-/health/live/"
|
||||||
|
@ -45,18 +43,15 @@ services = {
|
||||||
host = "node002"
|
host = "node002"
|
||||||
dns = [
|
dns = [
|
||||||
{
|
{
|
||||||
domain = "serguzim.me"
|
domain = "faas.serguzim.me"
|
||||||
target = "faas"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
domain = "serguzim.me"
|
domain = "serguzim.me"
|
||||||
target = "@"
|
|
||||||
name = "webpage-serguzim"
|
name = "webpage-serguzim"
|
||||||
alias = "faas"
|
alias = "faas"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
domain = "serguzim.me"
|
domain = "www.serguzim.me"
|
||||||
target = "www"
|
|
||||||
name = "webpage-serguzim-www"
|
name = "webpage-serguzim-www"
|
||||||
alias = "webpage-serguzim"
|
alias = "webpage-serguzim"
|
||||||
}
|
}
|
||||||
|
@ -74,8 +69,7 @@ services = {
|
||||||
name = "forgejo"
|
name = "forgejo"
|
||||||
host = "node003"
|
host = "node003"
|
||||||
dns = [{
|
dns = [{
|
||||||
domain = "serguzim.me"
|
domain = "git.serguzim.me"
|
||||||
target = "git"
|
|
||||||
}]
|
}]
|
||||||
backup = [{
|
backup = [{
|
||||||
name = "forgejo_data"
|
name = "forgejo_data"
|
||||||
|
@ -111,8 +105,7 @@ services = {
|
||||||
name = "gatus"
|
name = "gatus"
|
||||||
host = "node003"
|
host = "node003"
|
||||||
dns = [{
|
dns = [{
|
||||||
domain = "serguzim.me"
|
domain = "status.serguzim.me"
|
||||||
target = "status"
|
|
||||||
}]
|
}]
|
||||||
backup = [{
|
backup = [{
|
||||||
name = "gatus_data"
|
name = "gatus_data"
|
||||||
|
@ -128,8 +121,7 @@ services = {
|
||||||
name = "homebox"
|
name = "homebox"
|
||||||
host = "node003"
|
host = "node003"
|
||||||
dns = [{
|
dns = [{
|
||||||
domain = "serguzim.me"
|
domain = "inventory.serguzim.me"
|
||||||
target = "inventory"
|
|
||||||
}]
|
}]
|
||||||
backup = [{
|
backup = [{
|
||||||
name = "homebox_data"
|
name = "homebox_data"
|
||||||
|
@ -152,8 +144,7 @@ services = {
|
||||||
name = "immich"
|
name = "immich"
|
||||||
host = "node002"
|
host = "node002"
|
||||||
dns = [{
|
dns = [{
|
||||||
domain = "serguzim.me"
|
domain = "gallery.serguzim.me"
|
||||||
target = "gallery"
|
|
||||||
}]
|
}]
|
||||||
backup = [
|
backup = [
|
||||||
{
|
{
|
||||||
|
@ -178,8 +169,7 @@ services = {
|
||||||
name = "influxdb"
|
name = "influxdb"
|
||||||
host = "node002"
|
host = "node002"
|
||||||
dns = [{
|
dns = [{
|
||||||
domain = "serguzim.me"
|
domain = "tick.serguzim.me"
|
||||||
target = "tick"
|
|
||||||
}]
|
}]
|
||||||
backup = [{
|
backup = [{
|
||||||
name = "influxdb_data"
|
name = "influxdb_data"
|
||||||
|
@ -202,8 +192,7 @@ services = {
|
||||||
name = "jellyfin"
|
name = "jellyfin"
|
||||||
host = "node002"
|
host = "node002"
|
||||||
dns = [{
|
dns = [{
|
||||||
domain = "serguzim.me"
|
domain = "media.serguzim.me"
|
||||||
target = "media"
|
|
||||||
}]
|
}]
|
||||||
backup = [{
|
backup = [{
|
||||||
name = "jellyfin_config"
|
name = "jellyfin_config"
|
||||||
|
@ -226,8 +215,7 @@ services = {
|
||||||
name = "linkwarden"
|
name = "linkwarden"
|
||||||
host = "node003"
|
host = "node003"
|
||||||
dns = [{
|
dns = [{
|
||||||
domain = "serguzim.me"
|
domain = "bookmarks.serguzim.me"
|
||||||
target = "bookmarks"
|
|
||||||
}]
|
}]
|
||||||
monitoring = {
|
monitoring = {
|
||||||
url = "/api/v1/logins"
|
url = "/api/v1/logins"
|
||||||
|
@ -244,8 +232,7 @@ services = {
|
||||||
name = "mailcowdockerized"
|
name = "mailcowdockerized"
|
||||||
host = "node003"
|
host = "node003"
|
||||||
dns = [{
|
dns = [{
|
||||||
domain = "serguzim.me"
|
domain = "mail.serguzim.me"
|
||||||
target = "mail"
|
|
||||||
}]
|
}]
|
||||||
backup = [{
|
backup = [{
|
||||||
name = "mailcowdockerized"
|
name = "mailcowdockerized"
|
||||||
|
@ -264,12 +251,10 @@ services = {
|
||||||
host = "node002"
|
host = "node002"
|
||||||
dns = [
|
dns = [
|
||||||
{
|
{
|
||||||
domain = "serguzim.me"
|
domain = "s3.serguzim.me"
|
||||||
target = "s3"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
domain = "serguzim.me"
|
domain = "s3.serguzim.me"
|
||||||
target = "console.s3"
|
|
||||||
name = "minio-console"
|
name = "minio-console"
|
||||||
alias = "minio"
|
alias = "minio"
|
||||||
}
|
}
|
||||||
|
@ -292,8 +277,7 @@ services = {
|
||||||
name = "ntfy"
|
name = "ntfy"
|
||||||
host = "node003"
|
host = "node003"
|
||||||
dns = [{
|
dns = [{
|
||||||
domain = "serguzim.me"
|
domain = "push.serguzim.me"
|
||||||
target = "push"
|
|
||||||
}]
|
}]
|
||||||
backup = [{
|
backup = [{
|
||||||
name = "ntfy_data"
|
name = "ntfy_data"
|
||||||
|
@ -338,11 +322,9 @@ services = {
|
||||||
dns = [
|
dns = [
|
||||||
{
|
{
|
||||||
domain = "reitanlage-oranienburg.de"
|
domain = "reitanlage-oranienburg.de"
|
||||||
target = "@"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
domain = "reitanlage-oranienburg.de"
|
domain = "www.reitanlage-oranienburg.de"
|
||||||
target = "www"
|
|
||||||
name = "reitanlage_oranienburg-www"
|
name = "reitanlage_oranienburg-www"
|
||||||
alias = "reitanlage_oranienburg"
|
alias = "reitanlage_oranienburg"
|
||||||
}
|
}
|
||||||
|
@ -365,11 +347,9 @@ services = {
|
||||||
dns = [
|
dns = [
|
||||||
{
|
{
|
||||||
domain = "msrg.cc"
|
domain = "msrg.cc"
|
||||||
target = "@"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
domain = "msvg.cc"
|
domain = "msvg.cc"
|
||||||
target = "@"
|
|
||||||
name = "shlink-msvg"
|
name = "shlink-msvg"
|
||||||
alias = "shlink"
|
alias = "shlink"
|
||||||
}
|
}
|
||||||
|
@ -392,12 +372,10 @@ services = {
|
||||||
host = "node003"
|
host = "node003"
|
||||||
dns = [
|
dns = [
|
||||||
{
|
{
|
||||||
domain = "serguzim.me"
|
domain = "matrix.serguzim.me"
|
||||||
target = "matrix"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
domain = "msrg.cc"
|
domain = "matrix.msrg.cc"
|
||||||
target = "matrix"
|
|
||||||
name = "synapse-msrg"
|
name = "synapse-msrg"
|
||||||
alias = "synapse"
|
alias = "synapse"
|
||||||
}
|
}
|
||||||
|
@ -421,8 +399,7 @@ services = {
|
||||||
name = "tandoor"
|
name = "tandoor"
|
||||||
host = "node003"
|
host = "node003"
|
||||||
dns = [{
|
dns = [{
|
||||||
domain = "serguzim.me"
|
domain = "recipes.serguzim.me"
|
||||||
target = "recipes"
|
|
||||||
}]
|
}]
|
||||||
backup = [{
|
backup = [{
|
||||||
name = "tandoor_mediafiles"
|
name = "tandoor_mediafiles"
|
||||||
|
@ -442,12 +419,10 @@ services = {
|
||||||
host = "node003"
|
host = "node003"
|
||||||
dns = [
|
dns = [
|
||||||
{
|
{
|
||||||
domain = "serguzim.me"
|
domain = "ts.serguzim.me"
|
||||||
target = "ts"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
domain = "serguzim.me"
|
domain = "hook.serguzim.me"
|
||||||
target = "hook"
|
|
||||||
name = "teamspeak_fallback-hook"
|
name = "teamspeak_fallback-hook"
|
||||||
alias = "teamspeak_fallback"
|
alias = "teamspeak_fallback"
|
||||||
}
|
}
|
||||||
|
@ -476,8 +451,7 @@ services = {
|
||||||
name = "tinytinyrss"
|
name = "tinytinyrss"
|
||||||
host = "node001"
|
host = "node001"
|
||||||
dns = [{
|
dns = [{
|
||||||
domain = "serguzim.me"
|
domain = "rss.serguzim.me"
|
||||||
target = "rss"
|
|
||||||
}]
|
}]
|
||||||
monitoring = {
|
monitoring = {
|
||||||
url = "/tt-rss/"
|
url = "/tt-rss/"
|
||||||
|
@ -492,8 +466,7 @@ services = {
|
||||||
name = "umami"
|
name = "umami"
|
||||||
host = "node001"
|
host = "node001"
|
||||||
dns = [{
|
dns = [{
|
||||||
domain = "serguzim.me"
|
domain = "analytics.serguzim.me"
|
||||||
target = "analytics"
|
|
||||||
}]
|
}]
|
||||||
monitoring = {
|
monitoring = {
|
||||||
url = "/api/heartbeat"
|
url = "/api/heartbeat"
|
||||||
|
@ -508,8 +481,7 @@ services = {
|
||||||
name = "vikunja"
|
name = "vikunja"
|
||||||
host = "node003"
|
host = "node003"
|
||||||
dns = [{
|
dns = [{
|
||||||
domain = "serguzim.me"
|
domain = "todo.serguzim.me"
|
||||||
target = "todo"
|
|
||||||
}]
|
}]
|
||||||
backup = [{
|
backup = [{
|
||||||
name = "vikunja_data"
|
name = "vikunja_data"
|
||||||
|
@ -529,8 +501,7 @@ services = {
|
||||||
name = "wiki_js"
|
name = "wiki_js"
|
||||||
host = "node001"
|
host = "node001"
|
||||||
dns = [{
|
dns = [{
|
||||||
domain = "serguzim.me"
|
domain = "wiki.serguzim.me"
|
||||||
target = "wiki"
|
|
||||||
}]
|
}]
|
||||||
monitoring = {
|
monitoring = {
|
||||||
group = "4-services"
|
group = "4-services"
|
||||||
|
@ -545,8 +516,7 @@ services = {
|
||||||
name = "woodpecker"
|
name = "woodpecker"
|
||||||
host = "node003"
|
host = "node003"
|
||||||
dns = [{
|
dns = [{
|
||||||
domain = "serguzim.me"
|
domain = "ci.serguzim.me"
|
||||||
target = "ci"
|
|
||||||
}]
|
}]
|
||||||
monitoring = {
|
monitoring = {
|
||||||
url = "/healthz"
|
url = "/healthz"
|
||||||
|
|
|
@ -133,7 +133,6 @@ variable "services" {
|
||||||
host = string
|
host = string
|
||||||
dns = optional(list(object({
|
dns = optional(list(object({
|
||||||
domain = string
|
domain = string
|
||||||
target = string
|
|
||||||
name = optional(string)
|
name = optional(string)
|
||||||
alias = optional(string)
|
alias = optional(string)
|
||||||
})))
|
})))
|
||||||
|
|
|
@ -63,11 +63,7 @@ def parse_services(services, hosts):
|
||||||
|
|
||||||
domains = []
|
domains = []
|
||||||
for dns in data.get("dns") or []:
|
for dns in data.get("dns") or []:
|
||||||
domain = ""
|
domains.append(f"- {dns['domain']}")
|
||||||
if dns.get("target") != "@":
|
|
||||||
domain += f"{dns["target"]}."
|
|
||||||
domain += dns['domain']
|
|
||||||
domains.append(f"- {domain}")
|
|
||||||
|
|
||||||
data['key'] = svc_key
|
data['key'] = svc_key
|
||||||
data['label'] = "\\n".join([svc] + domains)
|
data['label'] = "\\n".join([svc] + domains)
|
||||||
|
|
Loading…
Reference in a new issue