Yes, template watches for changes in the Consul KV store.
In fact that's why I left the explicit
change_mode = "restart" (which is the default, so this isn't required, but it makes the restart trigger obvious). You can also have a look at the splay argument (to control how fast it reacts to changes). With this example, it's quite easy to test it with a simple curl in a loop to query your echo server, and in the meantime you update the value in Consul, and you can observe how the allocations change, or what is the returned value by the small echo service (i.e. when the allocation of the update is running)Re the missing value: the job will be "blocked" in pending mode because of the missing value
IN Nomad UI, for this new allocation you'll see in the recent event a
| Template |
=> Missing: kv.block(missing) |
event entry
Which you'll also see with the the nomad alloc status: (bold and underline added for emphasis)
$ nomad alloc status e68373f4
ID = e68373f4
Eval ID = e4d63ffe
Name = echo-consul.echo[0]
Node ID = bbd6bc91
Job ID = echo-consul
Job Version = 1
Client Status = pending
Client Description = <none>
Desired Status = run
Desired Description = <none>
Created = 2m36s ago
Modified = 2m24s ago
Task "http-server" is "pending"
Task Resources
CPU Memory Disk IOPS Addresses
Task Events:
Started At = N/A
Finished At = N/A
Total Restarts = 0
Last Restart = N/A
Recent Events:
Time Type Description
2018-09-12T13:21:04-04:00 Template Missing: kv.block(missing)
2018-09-12T13:21:01-04:00 Task Setup Building Task Directory
2018-09-12T13:21:01-04:00 Received Task received by client