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