Format terraform and nomad files

This commit is contained in:
2025-05-18 21:28:24 +10:00
parent 837cfdae68
commit 9cdd529633
12 changed files with 80 additions and 72 deletions

3
.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"recommendations": ["hashicorp.terraform", "fredwangwang.vscode-hcl-format"]
}

5
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,5 @@
{
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.formatOnSave": true
}

View File

@@ -11,7 +11,7 @@ terraform {
terraform { terraform {
required_providers { required_providers {
sops = { sops = {
source = "carlpett/sops" source = "carlpett/sops"
version = "~> 0.5" version = "~> 0.5"
} }
} }
@@ -58,11 +58,11 @@ resource "nomad_job" "pgbackup" {
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]
plugin_id = "smb" plugin_id = "smb"
volume_id = "unraid_database_dump" volume_id = "unraid_database_dump"
name = "unraid_database_dump" name = "unraid_database_dump"
external_id = "unraid_database_dump" external_id = "unraid_database_dump"

View File

@@ -13,11 +13,11 @@ resource "nomad_job" "webapp" {
resource "nomad_csi_volume_registration" "unraid_transfer" { 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 #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]
plugin_id = "smb" plugin_id = "smb"
volume_id = "unraid_transfer" volume_id = "unraid_transfer"
name = "unraid_transfer" name = "unraid_transfer"
external_id = "unraid_transfer" external_id = "unraid_transfer"
@@ -42,11 +42,11 @@ resource "nomad_job" "transfer" {
resource "nomad_csi_volume_registration" "unraid_appdata_transferfilebrowser" { 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 #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]
plugin_id = "smb" plugin_id = "smb"
volume_id = "unraid_appdata_transferfilebrowser" volume_id = "unraid_appdata_transferfilebrowser"
name = "unraid_appdata_transferfilebrowser" name = "unraid_appdata_transferfilebrowser"
external_id = "unraid_appdata_transferfilebrowser" external_id = "unraid_appdata_transferfilebrowser"

View File

@@ -1,13 +1,13 @@
job "csi-smb" { job "csi-smb" {
type = "system" type = "system"
group "smb" { group "smb" {
task "plugin" { task "plugin" {
driver = "docker" driver = "docker"
config { config {
image = "mcr.microsoft.com/k8s/csi/smb-csi:v1.7.0" image = "mcr.microsoft.com/k8s/csi/smb-csi:v1.7.0"
args = [ args = [
"--v=5", "--v=5",
"--nodeid=${attr.unique.hostname}", "--nodeid=${attr.unique.hostname}",
"--endpoint=unix:///csi/csi.sock", "--endpoint=unix:///csi/csi.sock",
@@ -17,9 +17,9 @@ job "csi-smb" {
} }
csi_plugin { csi_plugin {
id = "smb" id = "smb"
type = "node" type = "node"
mount_dir = "/csi" mount_dir = "/csi"
} }
resources { resources {

View File

@@ -34,13 +34,13 @@ job "pgadmin" {
} }
env = { env = {
PGADMIN_DEFAULT_EMAIL = "othrayte@gmail.com" PGADMIN_DEFAULT_EMAIL = "othrayte@gmail.com"
PGADMIN_DEFAULT_PASSWORD = "admin" PGADMIN_DEFAULT_PASSWORD = "admin"
PGADMIN_CONFIG_WTF_CSRF_ENABLED = "False" PGADMIN_CONFIG_WTF_CSRF_ENABLED = "False"
PGADMIN_CONFIG_WTF_CSRF_CHECK_DEFAULT = "False" PGADMIN_CONFIG_WTF_CSRF_CHECK_DEFAULT = "False"
PGADMIN_CONFIG_ENHANCED_COOKIE_PROTECTION = "False" PGADMIN_CONFIG_ENHANCED_COOKIE_PROTECTION = "False"
PGADMIN_CONFIG_SERVER_MODE = "False" PGADMIN_CONFIG_SERVER_MODE = "False"
PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED = "False" PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED = "False"
} }
resources { resources {
@@ -66,7 +66,7 @@ job "pgadmin" {
} }
template { template {
data = <<EOF data = <<EOF
{ {
"Servers": { "Servers": {
"1": { "1": {
@@ -85,12 +85,12 @@ EOF
} }
template { template {
data = <<EOF data = <<EOF
localhost:5432:*:postgres:{{ with nomadVar "nomad/jobs/postgres" }}{{ .postgress_password }}{{ end }} localhost:5432:*:postgres:{{ with nomadVar "nomad/jobs/postgres" }}{{ .postgress_password }}{{ end }}
EOF EOF
destination = "secrets/.pgpass" destination = "secrets/.pgpass"
perms = "0400" perms = "0400"
uid = 5050 # pgadmin uid = 5050 # pgadmin
} }
} }
} }

View File

@@ -2,8 +2,8 @@ job "pgbackup" {
type = "batch" type = "batch"
periodic { periodic {
# Note: To avoid issues with daylight savings, avoid scheduling jobs at 2am +/- 1 hour # Note: To avoid issues with daylight savings, avoid scheduling jobs at 2am +/- 1 hour
cron = "* 04 * * *" # Every day at 4am cron = "* 04 * * *" # Every day at 4am
time_zone = "Australia/Melbourne" time_zone = "Australia/Melbourne"
prohibit_overlap = true prohibit_overlap = true
} }
@@ -25,17 +25,17 @@ job "pgbackup" {
driver = "docker" driver = "docker"
config { config {
image = "postgres:latest" image = "postgres:latest"
command = "/bin/bash" command = "/bin/bash"
args = ["-c", "pg_dumpall -h localhost -U postgres > /backup/all_databases.sql"] args = ["-c", "pg_dumpall -h localhost -U postgres > /backup/all_databases.sql"]
volumes = [ "secrets/postgres_password:/run/secrets/postgres_password" ] volumes = ["secrets/postgres_password:/run/secrets/postgres_password"]
} }
user = "1000" user = "1000"
volume_mount { volume_mount {
volume = "unraid_database_dump" volume = "unraid_database_dump"
destination = "/backup" destination = "/backup"
read_only = false read_only = false
} }
@@ -44,12 +44,12 @@ job "pgbackup" {
} }
template { template {
data = <<EOF data = <<EOF
localhost:5432:*:postgres:{{ with nomadVar "nomad/jobs/postgres" }}{{ .postgress_password }}{{ end }} localhost:5432:*:postgres:{{ with nomadVar "nomad/jobs/postgres" }}{{ .postgress_password }}{{ end }}
EOF EOF
destination = "/secrets/postgres_password" destination = "/secrets/postgres_password"
perms = "0400" perms = "0400"
uid = 1000 uid = 1000
} }
resources { resources {
@@ -59,14 +59,14 @@ EOF
} }
volume "unraid_database_dump" { volume "unraid_database_dump" {
type = "csi" type = "csi"
read_only = false read_only = false
source = "unraid_database_dump" source = "unraid_database_dump"
access_mode = "single-node-writer" access_mode = "single-node-writer"
attachment_mode = "file-system" attachment_mode = "file-system"
mount_options { mount_options {
mount_flags = ["uid=1000","gid=0"] mount_flags = ["uid=1000", "gid=0"]
} }
} }

View File

@@ -28,9 +28,9 @@ job "postgres" {
} }
env { env {
POSTGRES_USER = "postgres" POSTGRES_USER = "postgres"
POSTGRES_PASSWORD_FILE = "/run/secrets/postgres_password" POSTGRES_PASSWORD_FILE = "/run/secrets/postgres_password"
POSTGRES_INITDB_ARGS = "--auth-host=md5" POSTGRES_INITDB_ARGS = "--auth-host=md5"
} }
resources { resources {
@@ -41,7 +41,7 @@ job "postgres" {
template { template {
# This securely sets the initial password for the postgres user, to change it later # This securely sets the initial password for the postgres user, to change it later
# you need to connect to the database and change it manually # you need to connect to the database and change it manually
data = <<EOF data = <<EOF
{{ with nomadVar "nomad/jobs/postgres" }}{{ .postgress_password }}{{ end }} {{ with nomadVar "nomad/jobs/postgres" }}{{ .postgress_password }}{{ end }}
EOF EOF
destination = "secrets/postgres_password" destination = "secrets/postgres_password"

View File

@@ -24,26 +24,26 @@ job "transfer" {
} }
volume "unraid_transfer" { volume "unraid_transfer" {
type = "csi" type = "csi"
read_only = false read_only = false
source = "unraid_transfer" source = "unraid_transfer"
access_mode = "single-node-writer" access_mode = "single-node-writer"
attachment_mode = "file-system" attachment_mode = "file-system"
mount_options { mount_options {
mount_flags = ["uid=911","gid=1000"] # linuxserver.io container services run as uid 911 mount_flags = ["uid=911", "gid=1000"] # linuxserver.io container services run as uid 911
} }
} }
volume "appdata" { volume "appdata" {
type = "csi" type = "csi"
read_only = false read_only = false
source = "unraid_appdata_transferfilebrowser" source = "unraid_appdata_transferfilebrowser"
access_mode = "single-node-writer" access_mode = "single-node-writer"
attachment_mode = "file-system" attachment_mode = "file-system"
mount_options { mount_options {
mount_flags = ["uid=911","gid=1000"] # linuxserver.io container services run as uid 911 mount_flags = ["uid=911", "gid=1000"] # linuxserver.io container services run as uid 911
} }
} }
@@ -63,13 +63,13 @@ job "transfer" {
volume_mount { volume_mount {
volume = "appdata" volume = "appdata"
destination = "/database" destination = "/database"
read_only = false read_only = false
} }
volume_mount { volume_mount {
volume = "unraid_transfer" volume = "unraid_transfer"
destination = "/srv" destination = "/srv"
read_only = false read_only = false
} }

View File

@@ -3,7 +3,7 @@ job "demo-webapp" {
count = 3 count = 3
network { network {
port "http"{ port "http" {
to = -1 to = -1
} }
} }
@@ -27,8 +27,8 @@ job "demo-webapp" {
task "server" { task "server" {
env { env {
PORT = "${NOMAD_PORT_http}" PORT = NOMAD_PORT_http
NODE_IP = "${NOMAD_IP_http}" NODE_IP = NOMAD_IP_http
} }
driver = "docker" driver = "docker"