Skip to content

Commit aae1324

Browse files
committed
only allow system to use raw_exec drivers now; no longer allow custom consul path
1 parent 89b9223 commit aae1324

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ There are various options that can be used in conjunction with the `project.noma
5959
NOMAD_VAR_CHECK_PATH
6060
NOMAD_VAR_CHECK_PROTOCOL
6161
NOMAD_VAR_CHECK_TIMEOUT
62-
NOMAD_VAR_CONSUL_PATH
6362
NOMAD_VAR_COUNT
6463
NOMAD_VAR_COUNT_CANARIES
6564
NOMAD_VAR_CPU

deploy.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,6 @@ function main() {
139139
fi
140140

141141

142-
if [[ "$NOMAD_ADDR" == *crawl*.archive.org:* ]]; then # nixxx
143-
export NOMAD_VAR_CONSUL_PATH='/usr/local/bin/consul'
144-
fi
145-
146-
147142
if [ "$CI_REGISTRY_READ_TOKEN" = "0" ]; then unset CI_REGISTRY_READ_TOKEN; fi
148143

149144
############################### NOMAD VARS SETUP ##############################
@@ -274,6 +269,24 @@ EOF
274269
fi
275270

276271

272+
# check the container related `driver` value(s).
273+
# scan entire complex project JSON for any key named `Driver` and write to a file
274+
nomad run -output -var-file=env.env project.hcl |jq '.. | .Driver? | select(. != null)' >| drivers.txt
275+
# there should be exactly one of these drivers in the HCL
276+
NUM=$(grep -icE '^"DRIVER_SET_AT_RUNTIME"$' drivers.txt |cat)
277+
if [ "$NUM" != 1 ]; then; echo 'bad drivers setup'; exit 1; fi
278+
# there should be 1+ of either of these drivers in the HCL
279+
NUM=$(grep -icE '^"(docker|podman)"$' drivers.txt |cat)
280+
if [ "$NUM" -lt 1 ]; then; echo 'drivers not located?'; exit 1; fi
281+
# there should be 0 of either of these drivers in the HCL
282+
NUM=$(grep -icE '^"(exec|raw_exec)"$' drivers.txt |cat)
283+
if [ "$NUM" != 0 ]; then; echo 'bad drivers in project'; exit 1; fi
284+
rm drivers.txt
285+
286+
# Now swap in the 'raw_exec' driver for the 'kv' task
287+
sed -ix 's/driver = "DRIVER_SET_AT_RUNTIME"/driver = "raw_exec"/' project.hcl
288+
289+
277290
if [ "$NOMAD_TOKEN" = test ]; then
278291
nomad run -output -var-file=env.env project.hcl >| project.json
279292
exit 0

project.nomad

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ variables {
6060
# only used for github repos
6161
CI_GITHUB_IMAGE = ""
6262

63-
CONSUL_PATH = "/usr/bin/consul"
64-
6563
FORCE_PULL = false
6664

6765
# For jobs with 2+ containers (and tasks) (so we can setup ports properly)
@@ -394,9 +392,9 @@ CI_COMMIT_SHA=${var.CI_COMMIT_SHA}
394392
for_each = slice(keys(var.NOMAD_SECRETS), 0, min(1, length(keys(var.NOMAD_SECRETS))))
395393
labels = ["kv"]
396394
content {
397-
driver = "raw_exec"
395+
driver = "DRIVER_SET_AT_RUNTIME"
398396
config {
399-
command = var.CONSUL_PATH
397+
command = "/usr/bin/consul"
400398
args = [ "kv", "put", var.SLUG, local.kv ]
401399
}
402400
lifecycle {

0 commit comments

Comments
 (0)