github.com/jrxfive/nomad@v0.6.1-0.20170802162750-1fef470e89bf/website/source/api/json-jobs.html.md (about) 1 --- 2 layout: api 3 page_title: JSON Job Specification - HTTP API 4 sidebar_current: api-jobs 5 description: |- 6 Jobs can also be specified via the HTTP API using a JSON format. This guide 7 discusses the job specification in JSON format. 8 --- 9 10 # JSON Job Specification 11 12 This guide covers the JSON syntax for submitting jobs to Nomad. A useful command 13 for generating valid JSON versions of HCL jobs is: 14 15 ```shell 16 $ nomad run -output my-job.nomad 17 ``` 18 19 ## Syntax 20 21 Below is the JSON representation of the job outputed by `$ nomad init`: 22 23 ```json 24 { 25 "Job": { 26 "ID": "example", 27 "Name": "example", 28 "Type": "service", 29 "Priority": 50, 30 "Datacenters": [ 31 "dc1" 32 ], 33 "TaskGroups": [{ 34 "Name": "cache", 35 "Count": 1, 36 "Tasks": [{ 37 "Name": "redis", 38 "Driver": "docker", 39 "User": "", 40 "Config": { 41 "image": "redis:3.2", 42 "port_map": [{ 43 "db": 6379 44 }] 45 }, 46 "Services": [{ 47 "Id": "", 48 "Name": "global-redis-check", 49 "Tags": [ 50 "global", 51 "cache" 52 ], 53 "PortLabel": "db", 54 "AddressMode": "", 55 "Checks": [{ 56 "Id": "", 57 "Name": "alive", 58 "Type": "tcp", 59 "Command": "", 60 "Args": null, 61 "Path": "", 62 "Protocol": "", 63 "PortLabel": "", 64 "Interval": 10000000000, 65 "Timeout": 2000000000, 66 "InitialStatus": "", 67 "TLSSkipVerify": false 68 }] 69 }], 70 "Resources": { 71 "CPU": 500, 72 "MemoryMB": 256, 73 "Networks": [{ 74 "Device": "", 75 "CIDR": "", 76 "IP": "", 77 "MBits": 10, 78 "DynamicPorts": [{ 79 "Label": "db", 80 "Value": 0 81 }] 82 }] 83 }, 84 "Leader": false 85 }], 86 "RestartPolicy": { 87 "Interval": 300000000000, 88 "Attempts": 10, 89 "Delay": 25000000000, 90 "Mode": "delay" 91 }, 92 "EphemeralDisk": { 93 "SizeMB": 300 94 } 95 }], 96 "Update": { 97 "MaxParallel": 1, 98 "MinHealthyTime": 10000000000, 99 "HealthyDeadline": 180000000000, 100 "AutoRevert": false, 101 "Canary": 0 102 } 103 } 104 } 105 ``` 106 107 The example JSON could be submitted as a job using the following: 108 109 ```text 110 $ curl -XPUT @d example.json http://127.0.0.1:4646/v1/job/example 111 { 112 "EvalID": "5d6ded54-0b2a-8858-6583-be5f476dec9d", 113 "EvalCreateIndex": 12, 114 "JobModifyIndex": 11, 115 "Warnings": "", 116 "Index": 12, 117 "LastContact": 0, 118 "KnownLeader": false 119 } 120 ``` 121 122 ## Syntax Reference 123 124 Following is a syntax reference for the possible keys that are supported and 125 their default values if any for each type of object. 126 127 ### Job 128 129 The `Job` object supports the following keys: 130 131 - `AllAtOnce` - Controls if the entire set of tasks in the job must 132 be placed atomically or if they can be scheduled incrementally. 133 This should only be used for special circumstances. Defaults to `false`. 134 135 - `Constraints` - A list to define additional constraints where a job can be 136 run. See the constraint reference for more details. 137 138 - `Datacenters` - A list of datacenters in the region which are eligible 139 for task placement. This must be provided, and does not have a default. 140 141 - `TaskGroups` - A list to define additional task groups. See the task group 142 reference for more details. 143 144 - `Meta` - Annotates the job with opaque metadata. 145 146 - `ParameterizedJob` - Specifies the job as a parameterized job such that it can 147 be dispatched against. The `ParamaterizedJob` object supports the following 148 attributes: 149 150 - `MetaOptional` - Specifies the set of metadata keys that may be provided 151 when dispatching against the job as a string array. 152 153 - `MetaRequired` - Specifies the set of metadata keys that must be provided 154 when dispatching against the job as a string array. 155 156 - `Payload` - Specifies the requirement of providing a payload when 157 dispatching against the parameterized job. The options for this field are 158 "optional", "required" and "forbidden". The default value is "optional". 159 160 - `Payload` - The payload may not be set when submitting a job but may appear in 161 a dispatched job. The `Payload` will be a base64 encoded string containing the 162 payload that the job was dispatched with. The `payload` has a **maximum size 163 of 16 KiB**. 164 165 - `Priority` - Specifies the job priority which is used to prioritize 166 scheduling and access to resources. Must be between 1 and 100 inclusively, 167 and defaults to 50. 168 169 - `Region` - The region to run the job in, defaults to "global". 170 171 - `Type` - Specifies the job type and switches which scheduler 172 is used. Nomad provides the `service`, `system` and `batch` schedulers, 173 and defaults to `service`. To learn more about each scheduler type visit 174 [here](/docs/runtime/schedulers.html) 175 176 - `Update` - Specifies an update strategy to be applied to all task groups 177 within the job. When specified both at the job level and the task group level, 178 the update blocks are merged with the task group's taking precedence. For more 179 details on the update stanza, please see below. 180 181 - `Periodic` - `Periodic` allows the job to be scheduled at fixed times, dates 182 or intervals. The periodic expression is always evaluated in the UTC 183 timezone to ensure consistent evaluation when Nomad Servers span multiple 184 time zones. The `Periodic` object is optional and supports the following attributes: 185 186 - `Enabled` - `Enabled` determines whether the periodic job will spawn child 187 jobs. 188 189 - `time_zone` - Specifies the time zone to evaluate the next launch interval 190 against. This is useful when wanting to account for day light savings in 191 various time zones. The time zone must be parsable by Golang's 192 [LoadLocation](https://golang.org/pkg/time/#LoadLocation). The default is 193 UTC. 194 195 - `SpecType` - `SpecType` determines how Nomad is going to interpret the 196 periodic expression. `cron` is the only supported `SpecType` currently. 197 198 - `Spec` - A cron expression configuring the interval the job is launched 199 at. Supports predefined expressions such as "@daily" and "@weekly" See 200 [here](https://github.com/gorhill/cronexpr#implementation) for full 201 documentation of supported cron specs and the predefined expressions. 202 203 - <a id="prohibit_overlap">`ProhibitOverlap`</a> - `ProhibitOverlap` can 204 be set to true to enforce that the periodic job doesn't spawn a new 205 instance of the job if any of the previous jobs are still running. It is 206 defaulted to false. 207 208 An example `periodic` block: 209 210 ```json 211 { 212 "Periodic": { 213 "Spec": "*/15 - *" 214 "SpecType": "cron", 215 "Enabled": true, 216 "ProhibitOverlap": true 217 } 218 } 219 ``` 220 221 ### Task Group 222 223 `TaskGroups` is a list of `TaskGroup` objects, each supports the following 224 attributes: 225 226 - `Constraints` - This is a list of `Constraint` objects. See the constraint 227 reference for more details. 228 229 - `Count` - Specifies the number of the task groups that should 230 be running. Must be non-negative, defaults to one. 231 232 - `Meta` - A key-value map that annotates the task group with opaque metadata. 233 234 - `Name` - The name of the task group. Must be specified. 235 236 - `RestartPolicy` - Specifies the restart policy to be applied to tasks in this group. 237 If omitted, a default policy for batch and non-batch jobs is used based on the 238 job type. See the [restart policy reference](#restart_policy) for more details. 239 240 - `EphemeralDisk` - Specifies the group's ephemeral disk requirements. See the 241 [ephemeral disk reference](#ephemeral_disk) for more details. 242 243 - `Update` - Specifies an update strategy to be applied to all task groups 244 within the job. When specified both at the job level and the task group level, 245 the update blocks are merged with the task group's taking precedence. For more 246 details on the update stanza, please see below. 247 248 - `Tasks` - A list of `Task` object that are part of the task group. 249 250 ### Task 251 252 The `Task` object supports the following keys: 253 254 - `Artifacts` - `Artifacts` is a list of `Artifact` objects which define 255 artifacts to be downloaded before the task is run. See the artifacts 256 reference for more details. 257 258 - `Config` - A map of key-value configuration passed into the driver 259 to start the task. The details of configurations are specific to 260 each driver. 261 262 - `Constraints` - This is a list of `Constraint` objects. See the constraint 263 reference for more details. 264 265 - `DispatchPayload` - Configures the task to have access to dispatch payloads. 266 The `DispatchPayload` object supports the following attributes: 267 268 - `File` - Specifies the file name to write the content of dispatch payload 269 to. The file is written relative to the task's local directory. 270 271 - `Driver` - Specifies the task driver that should be used to run the 272 task. See the [driver documentation](/docs/drivers/index.html) for what 273 is available. Examples include `docker`, `qemu`, `java`, and `exec`. 274 275 - `Env` - A map of key-value representing environment variables that 276 will be passed along to the running process. Nomad variables are 277 interpreted when set in the environment variable values. See the table of 278 interpreted variables [here](/docs/runtime/interpolation.html). 279 280 For example the below environment map will be reinterpreted: 281 282 ```json 283 { 284 "Env": { 285 "NODE_CLASS" : "${nomad.class}" 286 } 287 } 288 ``` 289 290 - `KillTimeout` - `KillTimeout` is a time duration in nanoseconds. It can be 291 used to configure the time between signaling a task it will be killed and 292 actually killing it. Drivers first sends a task the `SIGINT` signal and then 293 sends `SIGTERM` if the task doesn't die after the `KillTimeout` duration has 294 elapsed. The default `KillTimeout` is 5 seconds. 295 296 - `leader` - Specifies whether the task is the leader task of the task group. If 297 set to true, when the leader task completes, all other tasks within the task 298 group will be gracefully shutdown. 299 300 - `LogConfig` - This allows configuring log rotation for the `stdout` and `stderr` 301 buffers of a Task. See the log rotation reference below for more details. 302 303 - `Meta` - Annotates the task group with opaque metadata. 304 305 - `Name` - The name of the task. This field is required. 306 307 - `Resources` - Provides the resource requirements of the task. 308 See the resources reference for more details. 309 310 - `Services` - `Services` is a list of `Service` objects. Nomad integrates with 311 Consul for service discovery. A `Service` object represents a routable and 312 discoverable service on the network. Nomad automatically registers when a task 313 is started and de-registers it when the task transitions to the dead state. 314 [Click here](/docs/service-discovery/index.html) to learn more about 315 services. Below is the fields in the `Service` object: 316 317 - `Name`: An explicit name for the Service. Nomad will replace `${JOB}`, 318 `${TASKGROUP}` and `${TASK}` by the name of the job, task group or task, 319 respectively. `${BASE}` expands to the equivalent of 320 `${JOB}-${TASKGROUP}-${TASK}`, and is the default name for a Service. 321 Each service defined for a given task must have a distinct name, so if 322 a task has multiple services only one of them can use the default name 323 and the others must be explicitly named. Names must adhere to 324 [RFC-1123 ยง2.1](https://tools.ietf.org/html/rfc1123#section-2) and are 325 limited to alphanumeric and hyphen characters (i.e. `[a-z0-9\-]`), and be 326 less than 64 characters in length. 327 328 - `Tags`: A list of string tags associated with this Service. String 329 interpolation is supported in tags. 330 331 - `PortLabel`: `PortLabel` is an optional string and is used to associate 332 a port with the service. If specified, the port label must match one 333 defined in the resources block. This could be a label of either a 334 dynamic or a static port. 335 336 - `Checks`: `Checks` is an array of check objects. A check object defines a 337 health check associated with the service. Nomad supports the `script`, 338 `http` and `tcp` Consul Checks. Script checks are not supported for the 339 qemu driver since the Nomad client doesn't have access to the file system 340 of a task using the Qemu driver. 341 342 - `Type`: This indicates the check types supported by Nomad. Valid 343 options are currently `script`, `http` and `tcp`. 344 345 - `Name`: The name of the health check. 346 347 - `Interval`: This indicates the frequency of the health checks that 348 Consul will perform. 349 350 - `Timeout`: This indicates how long Consul will wait for a health 351 check query to succeed. 352 353 - `Path`: The path of the HTTP endpoint which Consul will query to query 354 the health of a service if the type of the check is `http`. Nomad 355 will add the IP of the service and the port, users are only required 356 to add the relative URL of the health check endpoint. 357 358 - `Protocol`: This indicates the protocol for the HTTP checks. Valid 359 options are `http` and `https`. We default it to `http`. 360 361 - `Command`: This is the command that the Nomad client runs for doing 362 script based health check. 363 364 - `Args`: Additional arguments to the `command` for script based health 365 checks. 366 367 - `TLSSkipVerify`: If true, Consul will not attempt to verify the 368 certificate when performing HTTPS checks. Requires Consul >= 0.7.2. 369 370 - `Templates` - Specifies the set of [`Template`](#template) objects to render for the task. 371 Templates can be used to inject both static and dynamic configuration with 372 data populated from environment variables, Consul and Vault. 373 374 - `User` - Set the user that will run the task. It defaults to the same user 375 the Nomad client is being run as. This can only be set on Linux platforms. 376 377 ### Resources 378 379 The `Resources` object supports the following keys: 380 381 - `CPU` - The CPU required in MHz. 382 383 - `IOPS` - The number of IOPS required given as a weight between 10-1000. 384 385 - `MemoryMB` - The memory required in MB. 386 387 - `Networks` - A list of network objects. 388 389 The Network object supports the following keys: 390 391 - `MBits` - The number of MBits in bandwidth required. 392 393 Nomad can allocate two types of ports to a task - Dynamic and Static/Reserved 394 ports. A network object allows the user to specify a list of `DynamicPorts` and 395 `ReservedPorts`. Each object supports the following attributes: 396 397 - `Value` - The port number for static ports. If the port is dynamic, then this 398 attribute is ignored. 399 - `Label` - The label to annotate a port so that it can be referred in the 400 service discovery block or environment variables. 401 402 <a id="ephemeral_disk"></a> 403 404 ### Ephemeral Disk 405 406 The `EphemeralDisk` object supports the following keys: 407 408 - `Migrate` - Specifies that the Nomad client should make a best-effort attempt 409 to migrate the data from a remote machine if placement cannot be made on the 410 original node. During data migration, the task will block starting until the 411 data migration has completed. Value is a boolean and the default is false. 412 413 - `SizeMB` - Specifies the size of the ephemeral disk in MB. Default is 300. 414 415 - `Sticky` - Specifies that Nomad should make a best-effort attempt to place the 416 updated allocation on the same machine. This will move the `local/` and 417 `alloc/data` directories to the new allocation. Value is a boolean and the 418 default is false. 419 420 <a id="restart_policy"></a> 421 422 ### Restart Policy 423 424 The `RestartPolicy` object supports the following keys: 425 426 - `Attempts` - `Attempts` is the number of restarts allowed in an `Interval`. 427 428 - `Interval` - `Interval` is a time duration that is specified in nanoseconds. 429 The `Interval` begins when the first task starts and ensures that only 430 `Attempts` number of restarts happens within it. If more than `Attempts` 431 number of failures happen, behavior is controlled by `Mode`. 432 433 - `Delay` - A duration to wait before restarting a task. It is specified in 434 nanoseconds. A random jitter of up to 25% is added to the delay. 435 436 - `Mode` - `Mode` is given as a string and controls the behavior when the task 437 fails more than `Attempts` times in an `Interval`. Possible values are listed 438 below: 439 440 - `delay` - `delay` will delay the next restart until the next `Interval` is 441 reached. 442 443 - `fail` - `fail` will not restart the task again. 444 445 ### Update 446 447 Specifies the task group update strategy. When omitted, rolling updates are 448 disabled. The update stanza can be specified at the job or task group level. 449 When specified at the job, the update stanza is inherited by all task groups. 450 When specified in both the job and in a task group, the stanzas are merged with 451 the task group's taking precedence. The `Update` object supports the following 452 attributes: 453 454 - `MaxParallel` - `MaxParallel` is given as an integer value and specifies 455 the number of tasks that can be updated at the same time. 456 457 - `HealthCheck` - Specifies the mechanism in which allocations health is 458 determined. The potential values are: 459 460 - "checks" - Specifies that the allocation should be considered healthy when 461 all of its tasks are running and their associated [checks][] are healthy, 462 and unhealthy if any of the tasks fail or not all checks become healthy. 463 This is a superset of "task_states" mode. 464 465 - "task_states" - Specifies that the allocation should be considered healthy 466 when all its tasks are running and unhealthy if tasks fail. 467 468 - "manual" - Specifies that Nomad should not automatically determine health 469 and that the operator will specify allocation health using the [HTTP 470 API](/api/deployments.html#set-allocation-health-in-deployment). 471 472 - `MinHealthyTime` - Specifies the minimum time the allocation must be in the 473 healthy state before it is marked as healthy and unblocks further allocations 474 from being updated. This is specified using a label suffix like "30s" or 475 "15m". 476 477 - `HealthyDeadline` - Specifies the deadline in which the allocation must be 478 marked as healthy after which the allocation is automatically transitioned to 479 unhealthy. This is specified using a label suffix like "2m" or "1h". 480 481 - `AutoRevert` - Specifies if the job should auto-revert to the last stable job 482 on deployment failure. A job is marked as stable if all the allocations as 483 part of its deployment were marked healthy. 484 485 - `Canary` - Specifies that changes to the job that would result in destructive 486 updates should create the specified number of canaries without stopping any 487 previous allocations. Once the operator determines the canaries are healthy, 488 they can be promoted which unblocks a rolling update of the remaining 489 allocations at a rate of `max_parallel`. 490 491 - `Stagger` - Specifies the delay between migrating allocations off nodes marked 492 for draining. This is specified using a label suffix like "30s" or "1h". 493 494 An example `Update` block: 495 496 ```json 497 { 498 "Update": { 499 "MaxParallel": 3, 500 "HealthCheck": "checks", 501 "MinHealthyTime": 15000000000, 502 "HealthyDeadline": 180000000000, 503 "AutoRevert": false, 504 "Canary": 1 505 } 506 } 507 ``` 508 509 ### Constraint 510 511 The `Constraint` object supports the following keys: 512 513 - `LTarget` - Specifies the attribute to examine for the 514 constraint. See the table of attributes [here](/docs/runtime/interpolation.html#interpreted_node_vars). 515 516 - `RTarget` - Specifies the value to compare the attribute against. 517 This can be a literal value, another attribute or a regular expression if 518 the `Operator` is in "regexp" mode. 519 520 - `Operand` - Specifies the test to be performed on the two targets. It takes on the 521 following values: 522 523 - `regexp` - Allows the `RTarget` to be a regular expression to be matched. 524 525 - `set_contains` - Allows the `RTarget` to be a comma separated list of values 526 that should be contained in the LTarget's value. 527 528 - `distinct_host` - If set, the scheduler will not co-locate any task groups on the same 529 machine. This can be specified as a job constraint which applies the 530 constraint to all task groups in the job, or as a task group constraint which 531 scopes the effect to just that group. The constraint may not be 532 specified at the task level. 533 534 Placing the constraint at both the job level and at the task group level is 535 redundant since when placed at the job level, the constraint will be applied 536 to all task groups. When specified, `LTarget` and `RTarget` should be 537 omitted. 538 539 - `distinct_property` - If set, the scheduler selects nodes that have a 540 distinct value of the specified property. The `RTarget` specifies how 541 many allocations are allowed to share the value of a property. The 542 `RTarget` must be 1 or greater and if omitted, defaults to 1. This can 543 be specified as a job constraint which applies the constraint to all 544 task groups in the job, or as a task group constraint which scopes the 545 effect to just that group. The constraint may not be specified at the 546 task level. 547 548 Placing the constraint at both the job level and at the task group level is 549 redundant since when placed at the job level, the constraint will be applied 550 to all task groups. When specified, `LTarget` should be the property 551 that should be distinct and and `RTarget` should be omitted. 552 553 - Comparison Operators - `=`, `==`, `is`, `!=`, `not`, `>`, `>=`, `<`, `<=`. The 554 ordering is compared lexically. 555 556 ### Log Rotation 557 558 The `LogConfig` object configures the log rotation policy for a task's `stdout` and 559 `stderr`. The `LogConfig` object supports the following attributes: 560 561 - `MaxFiles` - The maximum number of rotated files Nomad will retain for 562 `stdout` and `stderr`, each tracked individually. 563 564 - `MaxFileSizeMB` - The size of each rotated file. The size is specified in 565 `MB`. 566 567 If the amount of disk resource requested for the task is less than the total 568 amount of disk space needed to retain the rotated set of files, Nomad will return 569 a validation error when a job is submitted. 570 571 ```json 572 { 573 "LogConfig": { 574 "MaxFiles": 3, 575 "MaxFileSizeMB": 10 576 } 577 } 578 ``` 579 580 In the above example we have asked Nomad to retain 3 rotated files for both 581 `stderr` and `stdout` and size of each file is 10 MB. The minimum disk space that 582 would be required for the task would be 60 MB. 583 584 ### Artifact 585 586 Nomad downloads artifacts using 587 [`go-getter`](https://github.com/hashicorp/go-getter). The `go-getter` library 588 allows downloading of artifacts from various sources using a URL as the input 589 source. The key-value pairs given in the `options` block map directly to 590 parameters appended to the supplied `source` URL. These are then used by 591 `go-getter` to appropriately download the artifact. `go-getter` also has a CLI 592 tool to validate its URL and can be used to check if the Nomad `artifact` is 593 valid. 594 595 Nomad allows downloading `http`, `https`, and `S3` artifacts. If these artifacts 596 are archives (zip, tar.gz, bz2, etc.), these will be unarchived before the task 597 is started. 598 599 The `Artifact` object supports the following keys: 600 601 - `GetterSource` - The path to the artifact to download. 602 603 - `RelativeDest` - An optional path to download the artifact into relative to the 604 root of the task's directory. If omitted, it will default to `local/`. 605 606 - `GetterOptions` - A `map[string]string` block of options for `go-getter`. 607 Full documentation of supported options are available 608 [here](https://github.com/hashicorp/go-getter/tree/ef5edd3d8f6f482b775199be2f3734fd20e04d4a#protocol-specific-options-1). 609 An example is given below: 610 611 ```json 612 { 613 "GetterOptions": { 614 "checksum": "md5:c4aa853ad2215426eb7d70a21922e794", 615 616 "aws_access_key_id": "<id>", 617 "aws_access_key_secret": "<secret>", 618 "aws_access_token": "<token>" 619 } 620 } 621 ``` 622 623 An example of downloading and unzipping an archive is as simple as: 624 625 ```json 626 { 627 "Artifacts": [ 628 { 629 "GetterSource": "https://example.com/my.zip", 630 "GetterOptions": { 631 "checksum": "md5:7f4b3e3b4dd5150d4e5aaaa5efada4c3" 632 } 633 } 634 ] 635 } 636 ``` 637 638 #### S3 examples 639 640 S3 has several different types of addressing and more detail can be found 641 [here](http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#access-bucket-intro) 642 643 S3 region specific endpoints can be found 644 [here](http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region) 645 646 Path based style: 647 648 ```json 649 { 650 "Artifacts": [ 651 { 652 "GetterSource": "https://s3-us-west-2.amazonaws.com/my-bucket-example/my_app.tar.gz", 653 } 654 ] 655 } 656 ``` 657 658 or to override automatic detection in the URL, use the S3-specific syntax 659 660 ```json 661 { 662 "Artifacts": [ 663 { 664 "GetterSource": "s3::https://s3-eu-west-1.amazonaws.com/my-bucket-example/my_app.tar.gz", 665 } 666 ] 667 } 668 ``` 669 670 Virtual hosted based style 671 672 ```json 673 { 674 "Artifacts": [ 675 { 676 "GetterSource": "my-bucket-example.s3-eu-west-1.amazonaws.com/my_app.tar.gz", 677 } 678 ] 679 } 680 ``` 681 682 ### Template 683 684 The `Template` block instantiates an instance of a template renderer. This 685 creates a convenient way to ship configuration files that are populated from 686 environment variables, Consul data, Vault secrets, or just general 687 configurations within a Nomad task. 688 689 Nomad utilizes a tool called [Consul Template][ct]. Since Nomad v0.5.3, the 690 template can reference [Nomad's runtime environment variables][env]. For a full 691 list of the API template functions, please refer to the [Consul Template 692 README][ct]. 693 694 695 `Template` object supports following attributes: 696 697 - `ChangeMode` - Specifies the behavior Nomad should take if the rendered 698 template changes. The default value is `"restart"`. The possible values are: 699 700 - `"noop"` - take no action (continue running the task) 701 - `"restart"` - restart the task 702 - `"signal"` - send a configurable signal to the task 703 704 - `ChangeSignal` - Specifies the signal to send to the task as a string like 705 "SIGUSR1" or "SIGINT". This option is required if the `ChangeMode` is 706 `signal`. 707 708 - `DestPath` - Specifies the location where the resulting template should be 709 rendered, relative to the task directory. 710 711 - `EmbeddedTmpl` - Specifies the raw template to execute. One of `SourcePath` 712 or `EmbeddedTmpl` must be specified, but not both. This is useful for smaller 713 templates, but we recommend using `SourcePath` for larger templates. 714 715 - `Envvars` - Specifies the template should be read back as environment 716 variables for the task. 717 718 - `LeftDelim` - Specifies the left delimiter to use in the template. The default 719 is "{{" for some templates, it may be easier to use a different delimiter that 720 does not conflict with the output file itself. 721 722 - `Perms` - Specifies the rendered template's permissions. File permissions are 723 given as octal of the Unix file permissions rwxrwxrwx. 724 725 - `RightDelim` - Specifies the right delimiter to use in the template. The default 726 is "}}" for some templates, it may be easier to use a different delimiter that 727 does not conflict with the output file itself. 728 729 - `SourcePath` - Specifies the path to the template to be rendered. `SourcePath` 730 is mutually exclusive with `EmbeddedTmpl` attribute. The source can be fetched 731 using an [`Artifact`](#artifact) resource. The template must exist on the 732 machine prior to starting the task; it is not possible to reference a template 733 inside of a Docker container, for example. 734 735 - `Splay` - Specifies a random amount of time to wait between 0 ms and the given 736 splay value before invoking the change mode. Should be specified in 737 nanoseconds. 738 739 740 ```json 741 { 742 "Templates": [ 743 { 744 "SourcePath": "local/config.conf.tpl", 745 "DestPath": "local/config.conf", 746 "EmbeddedTmpl": "", 747 "ChangeMode": "signal", 748 "ChangeSignal": "SIGUSR1", 749 "Splay": 5000000000 750 } 751 ] 752 } 753 ``` 754 755 [ct]: https://github.com/hashicorp/consul-template "Consul Template by HashiCorp" 756 [env]: /docs/runtime/environment.html "Nomad Runtime Environment"