Sort parts of the nomad intra into folders

This should make finding things easier
This commit is contained in:
2025-10-22 22:02:25 +11:00
parent 8869bd1cb2
commit 92f60a7572
15 changed files with 176 additions and 25 deletions

54
2-nomad-config/1-data.tf Normal file
View File

@@ -0,0 +1,54 @@
module "data" {
source = "./1-data"
}
data "nomad_plugin" "smb" {
plugin_id = "smb"
wait_for_healthy = true
}
provider "postgresql" {
host = "jaglan-beta-m21.lan"
port = 5432
database = "postgres"
username = "postgres"
password = data.sops_file.secrets.data["postgres.postgres"]
sslmode = "disable"
connect_timeout = 15
}
# csi-smb.tf
moved {
from = nomad_job.csi-smb
to = module.data.nomad_job.csi-smb
}
# postgres.tf
moved {
from = nomad_job.postgres
to = module.data.nomad_job.postgres
}
moved {
from = nomad_job.pgadmin
to = module.data.nomad_job.pgadmin
}
moved {
from = nomad_job.pgbackup
to = module.data.nomad_job.pgbackup
}
moved {
from = nomad_variable.postgres
to = module.data.nomad_variable.postgres
}
moved {
from = nomad_csi_volume_registration.unraid_database_dump
to = module.data.nomad_csi_volume_registration.unraid_database_dump
}

View File

@@ -0,0 +1,5 @@
resource "nomad_job" "csi-smb" {
jobspec = file("${path.module}/csi-smb.nomad.hcl")
}

View File

@@ -0,0 +1,25 @@
terraform {
required_providers {
sops = {
source = "carlpett/sops"
version = "~> 0.5"
}
postgresql = {
source = "cyrilgdn/postgresql"
}
}
}
provider "nomad" {
address = "http://jaglan-beta-m20.lan:4646"
}
data "sops_file" "secrets" {
source_file = "secrets/secrets.enc.json"
}
data "nomad_plugin" "smb" {
plugin_id = "smb"
wait_for_healthy = true
}

View File

@@ -1,14 +1,14 @@
resource "nomad_job" "postgres" { resource "nomad_job" "postgres" {
jobspec = file("postgres.nomad.hcl") jobspec = file("${path.module}/postgres.nomad.hcl")
rerun_if_dead = true rerun_if_dead = true
} }
resource "nomad_job" "pgadmin" { resource "nomad_job" "pgadmin" {
jobspec = file("pgadmin.nomad.hcl") jobspec = file("${path.module}/pgadmin.nomad.hcl")
} }
resource "nomad_job" "pgbackup" { resource "nomad_job" "pgbackup" {
jobspec = file("pgbackup.nomad.hcl") jobspec = file("${path.module}/pgbackup.nomad.hcl")
} }
resource "nomad_variable" "postgres" { resource "nomad_variable" "postgres" {
@@ -18,16 +18,6 @@ resource "nomad_variable" "postgres" {
} }
} }
provider "postgresql" {
host = "jaglan-beta-m21.lan"
port = 5432
database = "postgres"
username = "postgres"
password = data.sops_file.secrets.data["postgres.postgres"]
sslmode = "disable"
connect_timeout = 15
}
resource "nomad_csi_volume_registration" "unraid_database_dump" { resource "nomad_csi_volume_registration" "unraid_database_dump" {
#Note: Before chaning the definition of this volume you need to stop the jobs that are using it #Note: Before chaning the definition of this volume you need to stop the jobs that are using it
depends_on = [data.nomad_plugin.smb] depends_on = [data.nomad_plugin.smb]

View File

@@ -0,0 +1,54 @@
module "ingress" {
source = "./2-ingress"
}
# traefik.tf
moved {
from = cloudflare_dns_record.othrayte-one
to = module.ingress.cloudflare_dns_record.othrayte-one
}
moved {
from = cloudflare_dns_record.star-othrayte-one
to = module.ingress.cloudflare_dns_record.star-othrayte-one
}
moved {
from = nomad_variable.traefik
to = module.ingress.nomad_variable.traefik
}
moved {
from = nomad_job.traefik
to = module.ingress.nomad_job.traefik
}
moved {
from = nomad_csi_volume_registration.unraid_appdata_traefik
to = module.ingress.nomad_csi_volume_registration.unraid_appdata_traefik
}
# authelia.tf
moved {
from = nomad_job.authelia
to = module.ingress.nomad_job.authelia
}
moved {
from = postgresql_role.authelia
to = module.ingress.postgresql_role.authelia
}
moved {
from = postgresql_database.authelia
to = module.ingress.postgresql_database.authelia
}
moved {
from = nomad_variable.authelia
to = module.ingress.nomad_variable.authelia
}

View File

@@ -1,5 +1,5 @@
resource "nomad_job" "authelia" { resource "nomad_job" "authelia" {
jobspec = file("authelia.nomad.hcl") jobspec = file("${path.module}/authelia.nomad.hcl")
} }
resource "postgresql_role" "authelia" { resource "postgresql_role" "authelia" {

View File

@@ -0,0 +1,33 @@
terraform {
required_providers {
sops = {
source = "carlpett/sops"
version = "~> 0.5"
}
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 5"
}
postgresql = {
source = "cyrilgdn/postgresql"
}
}
}
provider "nomad" {
address = "http://jaglan-beta-m20.lan:4646"
}
data "sops_file" "secrets" {
source_file = "secrets/secrets.enc.json"
}
provider "cloudflare" {
api_token = data.sops_file.secrets.data["cloudflare.api_token"]
}
data "nomad_plugin" "smb" {
plugin_id = "smb"
wait_for_healthy = true
}

View File

@@ -27,7 +27,7 @@ resource "nomad_variable" "traefik" {
} }
resource "nomad_job" "traefik" { resource "nomad_job" "traefik" {
jobspec = templatefile("traefik.nomad.hcl", { jobspec = templatefile("${path.module}/traefik.nomad.hcl", {
hass_magic_token = nonsensitive(data.sops_file.secrets.data["hass.magic-token"]) hass_magic_token = nonsensitive(data.sops_file.secrets.data["hass.magic-token"])
}) })
} }

View File

@@ -32,15 +32,6 @@ provider "cloudflare" {
api_token = data.sops_file.secrets.data["cloudflare.api_token"] api_token = data.sops_file.secrets.data["cloudflare.api_token"]
} }
resource "nomad_job" "csi-smb" {
jobspec = file("csi-smb.nomad.hcl")
}
data "nomad_plugin" "smb" {
plugin_id = "smb"
wait_for_healthy = true
}
resource "nomad_scheduler_config" "config" { resource "nomad_scheduler_config" "config" {
memory_oversubscription_enabled = true memory_oversubscription_enabled = true
preemption_config = { preemption_config = {
@@ -51,4 +42,3 @@ resource "nomad_scheduler_config" "config" {
} }
} }