github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/docs/job-specification/meta.mdx (about) 1 --- 2 layout: docs 3 page_title: meta Stanza - Job Specification 4 description: The "meta" stanza allows for user-defined arbitrary key-value pairs. 5 --- 6 7 # `meta` Stanza 8 9 <Placement 10 groups={[ 11 ['job', 'meta'], 12 ['job', 'group', 'meta'], 13 ['job', 'group', 'task', 'meta'], 14 ]} 15 /> 16 17 The `meta` stanza allows for user-defined arbitrary key-value pairs. It is 18 possible to use the `meta` stanza at the [job][], [group][], or [task][] level. 19 20 ```hcl 21 job "docs" { 22 meta { 23 my-key = "my-value" 24 } 25 26 group "example" { 27 meta { 28 my-key = "my-value" 29 } 30 31 task "server" { 32 meta { 33 my-key = "my-value" 34 } 35 } 36 } 37 } 38 ``` 39 40 Metadata is merged up the job specification, so metadata defined at the job 41 level applies to all groups and tasks within that job. Metadata defined at the 42 group layer applies to all tasks within that group. 43 44 Meta values are made available inside tasks as [runtime environment variables][env_meta]. 45 46 ## `meta` Parameters 47 48 The "parameters" for the `meta` stanza can be any key-value. The keys and values 49 are both of type `string`, but they can be specified as other types. They will 50 automatically be converted to strings. 51 52 ## `meta` Examples 53 54 The following examples only show the `meta` stanzas. Remember that the 55 `meta` stanza is only valid in the placements listed above. 56 57 ### Coercion 58 59 This example shows the different ways to specify key-value pairs. Internally, 60 these values will be stored as their string representation. No type information 61 is preserved. 62 63 ```hcl 64 meta { 65 key = "true" 66 key = true 67 68 key = 1.4 69 key = "1.4" 70 } 71 ``` 72 73 ### Interpolation 74 75 This example shows using [Nomad interpolation][interpolation] to populate 76 environment variables. 77 78 ```hcl 79 meta { 80 class = "${node.class}" 81 } 82 ``` 83 84 ### Meta keys with dots 85 86 Meta keys that aren't valid HCLv2 identifiers, like ones containing `.`, require an alternative map assignment syntax. 87 88 ```hcl 89 meta = { 90 "project.team" = "sre" 91 } 92 ``` 93 94 ## `meta` Usage Examples 95 96 ### Templates 97 98 To make use of a `meta` value in a template, refer to its environment variable 99 form. 100 101 ```hcl 102 template { 103 destination = "local/out.txt" 104 data = <<EOH 105 {{ env "NOMAD_META_mykey" }} 106 EOH 107 } 108 ``` 109 110 [job]: /docs/job-specification/job 'Nomad job Job Specification' 111 [group]: /docs/job-specification/group 'Nomad group Job Specification' 112 [task]: /docs/job-specification/task 'Nomad task Job Specification' 113 [interpolation]: /docs/runtime/interpolation 'Nomad interpolation' 114 [env_meta]: /docs/runtime/environment#meta