job "[[ .instance ]]-upgrade" { [[- $c := merge .pg . ]] [[ template "common/job_start" $c ]] type = "batch" meta { # Force job to be different for each execution run_uuid = "${uuidv4()}" } [[- if (not $c.upgrade.enabled) ]] # Postgres upgrader not explicitely enabled # Add a constraint to ensure it can't run constraint { attribute = "${attr.kernel.name}" value = "nonexistant" } [[- end ]] group "upgrade" { [[- $c := merge $c.upgrade $c ]] [[ template "common/volumes" $c ]] network { mode = "bridge" } task "upgrade" { driver = "[[ $c.nomad.driver ]]" config { [[ template "common/image" $c ]] } env { PG_FROM = "[[ $c.from ]]" PG_TO = "[[ $c.to ]]" PG_INITDB_OPTS = "[[ range $idx, $opt := .pg.server.initdb ]]--[[ $opt | regexp.Replace ":(\\s+)" "$1" ]] [[ end ]]" PG_UPGRADE_OPTS = "[[ range $idx, $opt := $c.options ]]--[[ $opt | regexp.Replace ":(\\s+)" "$1" | regexp.Replace "\"" "\\\"" ]] [[ end ]]" DO_PG_UPGRADE = "[[ $c.enabled | ternary "true" "false" ]]" } volume_mount { volume = "data" destination = "/data" } [[ template "common/resources" $c ]] } } }