github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/docs/commands/var/get.mdx (about) 1 --- 2 layout: docs 3 page_title: "Command: var get" 4 description: |- 5 The "var get" command retrieves the variable at the given path from 6 Nomad. If no variable exists at that path, an error is returned. 7 --- 8 9 # Command: var get 10 11 The `var get` command is used to get the contents of an existing [variable][]. 12 13 ## Usage 14 15 ```plaintext 16 nomad var get [options] <path> 17 ``` 18 19 If ACLs are enabled, this command requires a token with the `variables:read` 20 capability for the target variable's namespace and path. See the [ACL policy][] 21 documentation for details. 22 23 ## General Options 24 25 @include 'general_options.mdx' 26 27 ## Output Options 28 29 - `-item` `(string: "")`: Print only the value of the given item. Specifying 30 this option will take precedence over other formatting directives. The result 31 will not have a trailing newline making it ideal for piping to other 32 processes. 33 34 - `-out` `(enum: go-template | hcl | json | none | table )`: Format to render the 35 variable in. When using "go-template", you must provide the template content 36 with the `-template` option. Defaults to "table" when stdout is a terminal and 37 to "json" when stdout is redirected. 38 39 - `-template` `(string: "")` Template to render output with. Required when 40 output is "go-template". 41 42 ## Examples 43 44 Retrieve the variable stored at path "secret/creds": 45 46 ```shell-session 47 $ nomad var get secret/creds 48 Namespace = default 49 Path = secret/creds 50 Create Time = 2022-08-23T11:14:37-04:00 51 Check Index = 116 52 53 Items 54 passcode = my-long-passcode 55 ``` 56 57 Return only the "passcode" item from the variable stored at "secret/creds": 58 59 ```shell-session 60 $ nomad var get -item=passcode secret/creds 61 my-long-passcode 62 ``` 63 64 [variable]: /docs/concepts/variables 65 [ACL Policy]: /docs/other-specifications/acl-policy#variables