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 {
required_providers {
sops = {
source = "carlpett/sops"
source = "carlpett/sops"
version = "~> 0.5"
}
}
@@ -58,11 +58,11 @@ resource "nomad_job" "pgbackup" {
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]
depends_on = [data.nomad_plugin.smb]
plugin_id = "smb"
volume_id = "unraid_database_dump"
name = "unraid_database_dump"
volume_id = "unraid_database_dump"
name = "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" {
#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"
volume_id = "unraid_transfer"
name = "unraid_transfer"
volume_id = "unraid_transfer"
name = "unraid_transfer"
external_id = "unraid_transfer"
@@ -42,11 +42,11 @@ resource "nomad_job" "transfer" {
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]
depends_on = [data.nomad_plugin.smb]
plugin_id = "smb"
volume_id = "unraid_appdata_transferfilebrowser"
name = "unraid_appdata_transferfilebrowser"
volume_id = "unraid_appdata_transferfilebrowser"
name = "unraid_appdata_transferfilebrowser"
external_id = "unraid_appdata_transferfilebrowser"

View File

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

View File

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

View File

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

View File

@@ -28,9 +28,9 @@ job "postgres" {
}
env {
POSTGRES_USER = "postgres"
POSTGRES_USER = "postgres"
POSTGRES_PASSWORD_FILE = "/run/secrets/postgres_password"
POSTGRES_INITDB_ARGS = "--auth-host=md5"
POSTGRES_INITDB_ARGS = "--auth-host=md5"
}
resources {
@@ -41,7 +41,7 @@ job "postgres" {
template {
# 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
data = <<EOF
data = <<EOF
{{ with nomadVar "nomad/jobs/postgres" }}{{ .postgress_password }}{{ end }}
EOF
destination = "secrets/postgres_password"

View File

@@ -24,26 +24,26 @@ job "transfer" {
}
volume "unraid_transfer" {
type = "csi"
read_only = false
source = "unraid_transfer"
type = "csi"
read_only = false
source = "unraid_transfer"
access_mode = "single-node-writer"
attachment_mode = "file-system"
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" {
type = "csi"
read_only = false
source = "unraid_appdata_transferfilebrowser"
type = "csi"
read_only = false
source = "unraid_appdata_transferfilebrowser"
access_mode = "single-node-writer"
attachment_mode = "file-system"
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 = "appdata"
destination = "/database"
destination = "/database"
read_only = false
}
volume_mount {
volume = "unraid_transfer"
destination = "/srv"
destination = "/srv"
read_only = false
}

View File

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