resource "nomad_job" "postgres" {
  jobspec       = file("${path.module}/postgres.nomad.hcl")
  rerun_if_dead = true
}

resource "nomad_job" "pgadmin" {
  jobspec = file("${path.module}/pgadmin.nomad.hcl")
}

resource "nomad_job" "pgbackup" {
  jobspec = file("${path.module}/pgbackup.nomad.hcl")
}

resource "nomad_variable" "postgres" {
  path = "nomad/jobs/postgres"
  items = {
    postgres_password = data.sops_file.secrets.data["postgres.postgres"]
  }
}

module "unraid_smb_database_dump" {
  source = "../modules/unraid_smb"
  name   = "dump"
  id     = "unraid_database_dump"
  share  = "database-dump"
}
