357e7f4521
Also add links to the ACL policy reference and variables concepts docs near the top of the page.
66 lines
1.7 KiB
Plaintext
66 lines
1.7 KiB
Plaintext
---
|
|
layout: docs
|
|
page_title: "Command: var get"
|
|
description: |-
|
|
The "var get" command retrieves the variable at the given path from
|
|
Nomad. If no variable exists at that path, an error is returned.
|
|
---
|
|
|
|
# Command: var get
|
|
|
|
The `var get` command is used to get the contents of an existing [variable][].
|
|
|
|
## Usage
|
|
|
|
```plaintext
|
|
nomad var get [options] <path>
|
|
```
|
|
|
|
If ACLs are enabled, this command requires a token with the `variables:read`
|
|
capability for the target variable's namespace and path. See the [ACL policy][]
|
|
documentation for details.
|
|
|
|
## General Options
|
|
|
|
@include 'general_options.mdx'
|
|
|
|
## Output Options
|
|
|
|
- `-item` `(string: "")`: Print only the value of the given item. Specifying
|
|
this option will take precedence over other formatting directives. The result
|
|
will not have a trailing newline making it ideal for piping to other
|
|
processes.
|
|
|
|
- `-out` `(enum: go-template | hcl | json | none | table )`: Format to render the
|
|
variable in. When using "go-template", you must provide the template content
|
|
with the `-template` option. Defaults to "table" when stdout is a terminal and
|
|
to "json" when stdout is redirected.
|
|
|
|
- `-template` `(string: "")` Template to render output with. Required when
|
|
output is "go-template".
|
|
|
|
## Examples
|
|
|
|
Retrieve the variable stored at path "secret/creds":
|
|
|
|
```shell-session
|
|
$ nomad var get secret/creds
|
|
Namespace = default
|
|
Path = secret/creds
|
|
Create Time = 2022-08-23T11:14:37-04:00
|
|
Check Index = 116
|
|
|
|
Items
|
|
passcode = my-long-passcode
|
|
```
|
|
|
|
Return only the "passcode" item from the variable stored at "secret/creds":
|
|
|
|
```shell-session
|
|
$ nomad var get -item=passcode secret/creds
|
|
my-long-passcode
|
|
```
|
|
|
|
[variable]: /docs/concepts/variables
|
|
[ACL Policy]: /docs/other-specifications/acl-policy#variables
|