I ran the following job and it worked.
job "helloworld" {
datacenters = ["dc1","ap-northeast-1"]
group "hello" {
task "hello" {
driver = "docker"
config {
image = "alpine:3.16.0"
command = "/bin/sh"
args = ["-c", "echo 'Hello World!' && ls -l local/hello.txt && cat local/hello.txt && sleep infinity"]
}
template {
destination = "local/hello.txt"
data = <<EOF
hello!
EOF
}
resources {
cpu = 2
memory = 20
}
}
}
}
I whoud like to modify it as follows.
$ git diff
diff --git a/samples/hello.hcl b/samples/hello.hcl
index acc95e4..1ff95b5 100644
--- a/samples/hello.hcl
+++ b/samples/hello.hcl
@@ -13,7 +13,7 @@ job "helloworld" {
template {
destination = "local/hello.txt"
data = <<EOF
-hello!
+hello!{{name}}
EOF
}
resources {
When I run the job, it fails to start with the error below.
$ nomad alloc status c8e | tail -6
Time Type Description
2022-08-03T05:11:16Z Killing Sent interrupt. Waiting 5s before force killing
2022-08-03T05:11:14Z Alloc Unhealthy Unhealthy because of failed task
2022-08-03T05:11:14Z Killing Template failed: (dynamic): parse: template: :1: function "name" not defined
2022-08-03T05:11:14Z Task Setup Building Task Directory
2022-08-03T05:11:08Z Received Task received by client