github.com/hernad/nomad@v1.6.112/e2e/isolation/input/chroot_dl_exec.nomad (about) 1 # Copyright (c) HashiCorp, Inc. 2 # SPDX-License-Identifier: MPL-2.0 3 4 job "chroot_dl_exec" { 5 type = "batch" 6 7 constraint { 8 attribute = "${attr.kernel.name}" 9 value = "linux" 10 } 11 12 group "group" { 13 network { 14 mode = "host" 15 port "http" {} 16 } 17 18 task "script-writer" { 19 driver = "raw_exec" 20 config { 21 command = "/bin/bash" 22 args = [ 23 "-c", 24 "cd ${NOMAD_ALLOC_DIR} && chmod +x script.sh && tar -czf script.tar.gz script.sh" 25 ] 26 } 27 28 resources { 29 cpu = 50 30 memory = 50 31 } 32 33 template { 34 data = <<EOH 35 #!/bin/sh 36 echo this output is from a script 37 EOH 38 destination = "${NOMAD_ALLOC_DIR}/script.sh" 39 } 40 lifecycle { 41 hook = "prestart" 42 sidecar = false 43 } 44 } 45 46 task "file-server" { 47 driver = "raw_exec" 48 config { 49 command = "/usr/bin/python3" 50 args = ["-m", "http.server", "${NOMAD_PORT_http}", "--directory", "${NOMAD_ALLOC_DIR}"] 51 } 52 53 resources { 54 cpu = 50 55 memory = 50 56 } 57 lifecycle { 58 hook = "prestart" 59 sidecar = true 60 } 61 } 62 63 task "run-script" { 64 driver = "exec" 65 config { 66 command = "local/script.sh" 67 } 68 resources { 69 cpu = 50 70 memory = 50 71 } 72 artifact { 73 source = "http://localhost:${NOMAD_PORT_http}/script.tar.gz" 74 } 75 } 76 } 77 }