Files
nomad/website/content/docs/commands/var/get.mdx
Ashlee M Boyer 3444ece549 docs: Migrate link formats (#15779)
* Adding check-legacy-links-format workflow

* Adding test-link-rewrites workflow

* chore: updates link checker workflow hash

* Migrating links to new format

Co-authored-by: Kendall Strautman <kendallstrautman@gmail.com>
2023-01-25 09:31:14 -08:00

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]: /nomad/docs/concepts/variables
[ACL Policy]: /nomad/docs/other-specifications/acl-policy#variables