Get Postgres password from a Nomad var, and decomission old backup.

This commit is contained in:
2024-01-15 13:10:23 +00:00
parent 72f9319138
commit ea79ff2e52
3 changed files with 7 additions and 29 deletions

View File

@@ -10,7 +10,6 @@ job "postgres" {
to = 9187
}
port "admin" { }
port "backup_healthckeck" { }
}
task "postgres" {
@@ -23,7 +22,7 @@ job "postgres" {
}
env {
POSTGRES_PASSWORD = "${var.pg_password}"
POSTGRES_PASSWORD = "{{ with nomadVar \"secrets/postgresql\" }}{{ .postgres_password }}{{ end }}"
}
service {
@@ -52,7 +51,7 @@ job "postgres" {
}
env {
DATA_SOURCE_NAME = "postgresql://postgres:${var.pg_password}@${NOMAD_ADDR_db}/postgres?sslmode=disable"
DATA_SOURCE_NAME = "postgresql://postgres:{{ with nomadVar \"secrets/postgresql\" }}{{ .postgres_password }}{{ end }}@${NOMAD_ADDR_db}/postgres?sslmode=disable"
}
service {
@@ -106,34 +105,9 @@ EOH
]
}
}
task "backup" {
driver = "docker"
config {
image = "prodrigestivill/postgres-backup-local"
ports = [ "backup_healthckeck" ]
volumes = [ "/data/compute/appdata/pgbackup:/backups" ]
}
env {
POSTGRES_DB = "postgres"
POSTGRES_HOST = "${NOMAD_IP_db}"
POSTGRES_USER = "postgres"
POSTGRES_PASSWORD = "${var.pg_password}"
POSTGRES_CLUSTER = "TRUE"
POSTGRES_EXTRA_OPTS = ""
HEALTHCHECK_PORT = "${NOMAD_PORT_backup_healthckeck}"
}
}
}
}
variable "pg_password" {
type = string
default = "Faelaishewohlees4nei"
}
variable "default_email" {
type = string
default = "petru@paler.net"