github.com/hernad/nomad@v1.6.112/e2e/consultemplate/input/templating.nomad (about) 1 # Copyright (c) HashiCorp, Inc. 2 # SPDX-License-Identifier: MPL-2.0 3 4 job "templating" { 5 datacenters = ["dc1", "dc2"] 6 7 constraint { 8 attribute = "${attr.kernel.name}" 9 value = "linux" 10 } 11 12 group "docker_downstream" { 13 14 task "task" { 15 16 driver = "docker" 17 18 config { 19 image = "busybox:1" 20 command = "/bin/sh" 21 args = ["-c", "sleep 300"] 22 } 23 24 template { 25 data = <<EOT 26 {{ range service "upstream-service" }} 27 server {{ .Name }} {{ .Address }}:{{ .Port }}{{ end }} 28 EOT 29 30 destination = "${NOMAD_TASK_DIR}/services.conf" 31 change_mode = "noop" 32 } 33 34 template { 35 data = <<EOT 36 --- 37 key: {{ key "consultemplatetest" }} 38 job: {{ env "NOMAD_JOB_NAME" }} 39 EOT 40 41 destination = "${NOMAD_TASK_DIR}/kv.yml" 42 change_mode = "restart" 43 } 44 45 resources { 46 cpu = 128 47 memory = 64 48 } 49 } 50 } 51 52 group "exec_downstream" { 53 54 task "task" { 55 56 driver = "exec" 57 58 config { 59 command = "/bin/sh" 60 args = ["-c", "sleep 300"] 61 } 62 63 template { 64 data = <<EOT 65 {{ range service "upstream-service" }} 66 server {{ .Name }} {{ .Address }}:{{ .Port }}{{ end }} 67 EOT 68 69 destination = "${NOMAD_TASK_DIR}/services.conf" 70 change_mode = "noop" 71 } 72 73 template { 74 data = <<EOT 75 --- 76 key: {{ key "consultemplatetest" }} 77 job: {{ env "NOMAD_JOB_NAME" }} 78 EOT 79 destination = "${NOMAD_TASK_DIR}/kv.yml" 80 change_mode = "restart" 81 } 82 83 resources { 84 cpu = 128 85 memory = 64 86 } 87 } 88 } 89 90 group "upstream" { 91 92 count = 2 93 94 network { 95 mode = "bridge" 96 port "web" { 97 to = -1 98 } 99 } 100 101 service { 102 name = "upstream-service" 103 port = "web" 104 } 105 106 task "task" { 107 108 driver = "exec" 109 110 config { 111 command = "/bin/sh" 112 args = ["-c", "sleep 300"] 113 } 114 115 resources { 116 cpu = 128 117 memory = 64 118 } 119 } 120 } 121 122 }