Move each service to it's own tf file
This commit is contained in:
@@ -1,141 +0,0 @@
|
||||
terraform {
|
||||
backend "local" {
|
||||
path = "./.tfstate/terraform.tfstate"
|
||||
}
|
||||
}
|
||||
|
||||
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-m01.othrayte.one:4646"
|
||||
}
|
||||
|
||||
data "sops_file" "secrets" {
|
||||
source_file = "secrets.enc.json"
|
||||
}
|
||||
|
||||
provider "cloudflare" {
|
||||
api_token = data.sops_file.secrets.data["cloudflare.api_token"]
|
||||
}
|
||||
|
||||
// Networking
|
||||
|
||||
resource "cloudflare_dns_record" "othrayte-one" {
|
||||
comment = "othrayte.one proxy to internal IP for traefik"
|
||||
zone_id = "2616ab2a44d0645b03fbc3106c79bd99"
|
||||
type = "AAAA"
|
||||
name = "othrayte.one"
|
||||
content = data.sops_file.secrets.data["cloudflare.direct_ip6"]
|
||||
proxied = true
|
||||
ttl = 1 # Auto
|
||||
}
|
||||
|
||||
resource "cloudflare_dns_record" "star-othrayte-one" {
|
||||
comment = "*.othrayte.one proxy to internal IP for traefik"
|
||||
zone_id = "2616ab2a44d0645b03fbc3106c79bd99"
|
||||
type = "AAAA"
|
||||
name = "*"
|
||||
content = data.sops_file.secrets.data["cloudflare.direct_ip6"]
|
||||
proxied = true
|
||||
ttl = 1 # Auto
|
||||
}
|
||||
|
||||
resource "nomad_job" "traefik" {
|
||||
jobspec = file("traefik.nomad.hcl")
|
||||
}
|
||||
|
||||
// Authentication
|
||||
|
||||
resource "nomad_job" "authelia" {
|
||||
jobspec = file("authelia.nomad.hcl")
|
||||
}
|
||||
|
||||
resource "nomad_variable" "authelia" {
|
||||
path = "nomad/jobs/authelia"
|
||||
items = {
|
||||
session_secret = data.sops_file.secrets.data["authelia.session_secret"]
|
||||
jwt_secret = data.sops_file.secrets.data["authelia.jwt_secret"]
|
||||
encryption_key = data.sops_file.secrets.data["authelia.encryption_key"]
|
||||
}
|
||||
}
|
||||
|
||||
// Data
|
||||
|
||||
resource "nomad_job" "csi-smb" {
|
||||
jobspec = file("csi-smb.nomad.hcl")
|
||||
}
|
||||
|
||||
data "nomad_plugin" "smb" {
|
||||
plugin_id = "smb"
|
||||
wait_for_healthy = true
|
||||
}
|
||||
|
||||
resource "nomad_job" "postgres" {
|
||||
jobspec = file("postgres.nomad.hcl")
|
||||
}
|
||||
|
||||
resource "nomad_job" "pgadmin" {
|
||||
jobspec = file("pgadmin.nomad.hcl")
|
||||
}
|
||||
|
||||
resource "nomad_job" "pgbackup" {
|
||||
jobspec = file("pgbackup.nomad.hcl")
|
||||
}
|
||||
|
||||
resource "nomad_variable" "postgres" {
|
||||
path = "nomad/jobs/postgres"
|
||||
items = {
|
||||
postgres_password = data.sops_file.secrets.data["postgres.postgres"]
|
||||
}
|
||||
}
|
||||
|
||||
provider "postgresql" {
|
||||
#host = "jaglan-beta-m01.othrayte.one"
|
||||
host = "192.168.1.235"
|
||||
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" {
|
||||
#Note: Before chaning the definition of this volume you need to stop the jobs that are using it
|
||||
depends_on = [data.nomad_plugin.smb]
|
||||
plugin_id = "smb"
|
||||
|
||||
volume_id = "unraid_database_dump"
|
||||
name = "unraid_database_dump"
|
||||
|
||||
external_id = "unraid_database_dump"
|
||||
|
||||
capability {
|
||||
access_mode = "single-node-writer"
|
||||
attachment_mode = "file-system"
|
||||
}
|
||||
|
||||
context = {
|
||||
source = "//192.168.1.192/database-dump"
|
||||
}
|
||||
|
||||
secrets = {
|
||||
"username" = "nomad"
|
||||
"password" = data.sops_file.secrets.data["unraid.nomad"]
|
||||
}
|
||||
}
|
||||
|
||||
12
2-nomad-config/authelia.tf
Normal file
12
2-nomad-config/authelia.tf
Normal file
@@ -0,0 +1,12 @@
|
||||
resource "nomad_job" "authelia" {
|
||||
jobspec = file("authelia.nomad.hcl")
|
||||
}
|
||||
|
||||
resource "nomad_variable" "authelia" {
|
||||
path = "nomad/jobs/authelia"
|
||||
items = {
|
||||
session_secret = data.sops_file.secrets.data["authelia.session_secret"]
|
||||
jwt_secret = data.sops_file.secrets.data["authelia.jwt_secret"]
|
||||
encryption_key = data.sops_file.secrets.data["authelia.encryption_key"]
|
||||
}
|
||||
}
|
||||
@@ -1,68 +1,8 @@
|
||||
resource "nomad_job" "glance" {
|
||||
jobspec = file("glance.nomad.hcl")
|
||||
}
|
||||
|
||||
resource "nomad_job" "transfer" {
|
||||
jobspec = file("transfer.nomad.hcl")
|
||||
}
|
||||
|
||||
resource "nomad_csi_volume_registration" "unraid_transfer" {
|
||||
#Note: Before chaning the definition of this volume you need to stop the jobs that are using it
|
||||
depends_on = [data.nomad_plugin.smb]
|
||||
plugin_id = "smb"
|
||||
|
||||
volume_id = "unraid_transfer"
|
||||
name = "unraid_transfer"
|
||||
|
||||
external_id = "unraid_transfer"
|
||||
|
||||
capability {
|
||||
access_mode = "single-node-writer"
|
||||
attachment_mode = "file-system"
|
||||
}
|
||||
|
||||
context = {
|
||||
source = "//192.168.1.192/transfer"
|
||||
}
|
||||
|
||||
secrets = {
|
||||
"username" = "anon"
|
||||
"password" = ""
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
resource "nomad_csi_volume_registration" "unraid_appdata_transferfilebrowser" {
|
||||
#Note: Before chaning the definition of this volume you need to stop the jobs that are using it
|
||||
depends_on = [data.nomad_plugin.smb]
|
||||
plugin_id = "smb"
|
||||
|
||||
volume_id = "unraid_appdata_transferfilebrowser"
|
||||
name = "unraid_appdata_transferfilebrowser"
|
||||
|
||||
external_id = "unraid_appdata_transferfilebrowser"
|
||||
|
||||
capability {
|
||||
access_mode = "single-node-writer"
|
||||
attachment_mode = "file-system"
|
||||
}
|
||||
|
||||
context = {
|
||||
source = "//192.168.1.192/appdata"
|
||||
subDir = "transferfilebrowser" # Note: Needs to be manually created on the share
|
||||
}
|
||||
|
||||
secrets = {
|
||||
"username" = "nomad"
|
||||
"password" = data.sops_file.secrets.data["unraid.nomad"]
|
||||
}
|
||||
}
|
||||
|
||||
resource "cloudflare_dns_record" "git-othrayte-one" {
|
||||
comment = "git.othrayte.one maps to tailscale fqdn"
|
||||
zone_id = "2616ab2a44d0645b03fbc3106c79bd99"
|
||||
type = "CNAME"
|
||||
name = "git"
|
||||
name = "git.othrayte.one"
|
||||
content = "git.tail15856.ts.net"
|
||||
ttl = 1 # Auto
|
||||
}
|
||||
@@ -117,5 +57,3 @@ resource "nomad_csi_volume_registration" "unraid_appdata_gitea" {
|
||||
"password" = data.sops_file.secrets.data["unraid.nomad"]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
3
2-nomad-config/glance.tf
Normal file
3
2-nomad-config/glance.tf
Normal file
@@ -0,0 +1,3 @@
|
||||
resource "nomad_job" "glance" {
|
||||
jobspec = file("glance.nomad.hcl")
|
||||
}
|
||||
42
2-nomad-config/main.tf
Normal file
42
2-nomad-config/main.tf
Normal file
@@ -0,0 +1,42 @@
|
||||
terraform {
|
||||
backend "local" {
|
||||
path = "./.tfstate/terraform.tfstate"
|
||||
}
|
||||
}
|
||||
|
||||
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-m01.othrayte.one:4646"
|
||||
}
|
||||
|
||||
data "sops_file" "secrets" {
|
||||
source_file = "secrets.enc.json"
|
||||
}
|
||||
|
||||
provider "cloudflare" {
|
||||
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
|
||||
}
|
||||
54
2-nomad-config/postgres.tf
Normal file
54
2-nomad-config/postgres.tf
Normal file
@@ -0,0 +1,54 @@
|
||||
resource "nomad_job" "postgres" {
|
||||
jobspec = file("postgres.nomad.hcl")
|
||||
}
|
||||
|
||||
resource "nomad_job" "pgadmin" {
|
||||
jobspec = file("pgadmin.nomad.hcl")
|
||||
}
|
||||
|
||||
resource "nomad_job" "pgbackup" {
|
||||
jobspec = file("pgbackup.nomad.hcl")
|
||||
}
|
||||
|
||||
resource "nomad_variable" "postgres" {
|
||||
path = "nomad/jobs/postgres"
|
||||
items = {
|
||||
postgres_password = data.sops_file.secrets.data["postgres.postgres"]
|
||||
}
|
||||
}
|
||||
|
||||
provider "postgresql" {
|
||||
#host = "jaglan-beta-m01.othrayte.one"
|
||||
host = "192.168.1.235"
|
||||
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" {
|
||||
#Note: Before chaning the definition of this volume you need to stop the jobs that are using it
|
||||
depends_on = [data.nomad_plugin.smb]
|
||||
plugin_id = "smb"
|
||||
|
||||
volume_id = "unraid_database_dump"
|
||||
name = "unraid_database_dump"
|
||||
|
||||
external_id = "unraid_database_dump"
|
||||
|
||||
capability {
|
||||
access_mode = "single-node-writer"
|
||||
attachment_mode = "file-system"
|
||||
}
|
||||
|
||||
context = {
|
||||
source = "//192.168.1.192/database-dump"
|
||||
}
|
||||
|
||||
secrets = {
|
||||
"username" = "nomad"
|
||||
"password" = data.sops_file.secrets.data["unraid.nomad"]
|
||||
}
|
||||
}
|
||||
23
2-nomad-config/traefik.tf
Normal file
23
2-nomad-config/traefik.tf
Normal file
@@ -0,0 +1,23 @@
|
||||
resource "cloudflare_dns_record" "othrayte-one" {
|
||||
comment = "othrayte.one proxy to internal IP for traefik"
|
||||
zone_id = "2616ab2a44d0645b03fbc3106c79bd99"
|
||||
type = "AAAA"
|
||||
name = "othrayte.one"
|
||||
content = data.sops_file.secrets.data["cloudflare.direct_ip6"]
|
||||
proxied = true
|
||||
ttl = 1 # Auto
|
||||
}
|
||||
|
||||
resource "cloudflare_dns_record" "star-othrayte-one" {
|
||||
comment = "*.othrayte.one proxy to internal IP for traefik"
|
||||
zone_id = "2616ab2a44d0645b03fbc3106c79bd99"
|
||||
type = "AAAA"
|
||||
name = "*.othrayte.one"
|
||||
content = data.sops_file.secrets.data["cloudflare.direct_ip6"]
|
||||
proxied = true
|
||||
ttl = 1 # Auto
|
||||
}
|
||||
|
||||
resource "nomad_job" "traefik" {
|
||||
jobspec = file("traefik.nomad.hcl")
|
||||
}
|
||||
54
2-nomad-config/transfer.tf
Normal file
54
2-nomad-config/transfer.tf
Normal file
@@ -0,0 +1,54 @@
|
||||
resource "nomad_job" "transfer" {
|
||||
jobspec = file("transfer.nomad.hcl")
|
||||
}
|
||||
|
||||
resource "nomad_csi_volume_registration" "unraid_transfer" {
|
||||
#Note: Before chaning the definition of this volume you need to stop the jobs that are using it
|
||||
depends_on = [data.nomad_plugin.smb]
|
||||
plugin_id = "smb"
|
||||
|
||||
volume_id = "unraid_transfer"
|
||||
name = "unraid_transfer"
|
||||
|
||||
external_id = "unraid_transfer"
|
||||
|
||||
capability {
|
||||
access_mode = "single-node-writer"
|
||||
attachment_mode = "file-system"
|
||||
}
|
||||
|
||||
context = {
|
||||
source = "//192.168.1.192/transfer"
|
||||
}
|
||||
|
||||
secrets = {
|
||||
"username" = "anon"
|
||||
"password" = ""
|
||||
}
|
||||
}
|
||||
|
||||
resource "nomad_csi_volume_registration" "unraid_appdata_transferfilebrowser" {
|
||||
#Note: Before chaning the definition of this volume you need to stop the jobs that are using it
|
||||
depends_on = [data.nomad_plugin.smb]
|
||||
plugin_id = "smb"
|
||||
|
||||
volume_id = "unraid_appdata_transferfilebrowser"
|
||||
name = "unraid_appdata_transferfilebrowser"
|
||||
|
||||
external_id = "unraid_appdata_transferfilebrowser"
|
||||
|
||||
capability {
|
||||
access_mode = "single-node-writer"
|
||||
attachment_mode = "file-system"
|
||||
}
|
||||
|
||||
context = {
|
||||
source = "//192.168.1.192/appdata"
|
||||
subDir = "transferfilebrowser" # Note: Needs to be manually created on the share
|
||||
}
|
||||
|
||||
secrets = {
|
||||
"username" = "nomad"
|
||||
"password" = data.sops_file.secrets.data["unraid.nomad"]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user