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