Files
nomad/website/content/docs/commands/var/get.mdx
Phil Renaud 35e1ea4328 [cli] UI URL hints for common CLI commands (#24454)
* Basic implementation for server members and node status

* Commands for alloc status and job status

* -ui flag for most commands

* url hints for variables

* url hints for job dispatch, evals, and deployments

* agent config ui.cli_url_links to disable

* Fix an issue where path prefix was presumed for variables

* driver uncomment and general cleanup

* -ui flag on the generic status endpoint

* Job run command gets namespaces, and no longer gets ui hints for --output flag

* Dispatch command hints get a namespace, and bunch o tests

* Lots of tests depend on specific output, so let's not mess with them

* figured out what flagAddress is all about for testServer, oof

* Parallel outside of test instances

* Browser-opening test, sorta

* Env var for disabling/enabling CLI hints

* Addressing a few PR comments

* CLI docs available flags now all have -ui

* PR comments addressed; switched the env var to be consistent and scrunched monitor-adjacent hints a bit more

* ui.Output -> ui.Warn; moves hints from stdout to stderr

* isTerminal check and parseBool on command option

* terminal.IsTerminal check removed for test-runner-not-being-terminal reasons
2025-03-07 13:23:35 -05:00

68 lines
1.8 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".
- `-ui`: Open the variable page in the browser.
## 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