Files
nomad/website/content/commands/var/put.mdx
Aimee Ukasick 53b083b8c5 Docs: Nomad IA (#26063)
* Move commands from docs to its own root-level directory

* temporarily use modified dev-portal branch with nomad ia changes

* explicitly clone nomad ia exp branch

* retrigger build, fixed dev-portal broken build

* architecture, concepts and get started individual pages

* fix get started section destinations

* reference section

* update repo comment in website-build.sh to show branch

* docs nav file update capitalization

* update capitalization to force deploy

* remove nomad-vs-kubernetes dir; move content to what is nomad pg

* job section

* Nomad operations category, deploy section

* operations category, govern section

* operations - manage

* operations/scale; concepts scheduling fix

* networking

* monitor

* secure section

* remote auth-methods folder and move up pages to sso; linkcheck

* Fix install2deploy redirects

* fix architecture redirects

* Job section: Add missing section index pages

* Add section index pages so breadcrumbs build correctly

* concepts/index fix front matter indentation

* move task driver plugin config to new deploy section

* Finish adding full URL to tutorials links in nav

* change SSO to Authentication in nav and file system

* Docs NomadIA: Move tutorials into NomadIA branch (#26132)

* Move governance and policy from tutorials to docs

* Move tutorials content to job-declare section

* run jobs section

* stateful workloads

* advanced job scheduling

* deploy section

* manage section

* monitor section

* secure/acl and secure/authorization

* fix example that contains an unseal key in real format

* remove images from sso-vault

* secure/traffic

* secure/workload-identities

* vault-acl change unseal key and root token in command output sample

* remove lines from sample output

* fix front matter

* move nomad pack tutorials to tools

* search/replace /nomad/tutorials links

* update acl overview with content from deleted architecture/acl

* fix spelling mistake

* linkcheck - fix broken links

* fix link to Nomad variables tutorial

* fix link to Prometheus tutorial

* move who uses Nomad to use cases page; move spec/config shortcuts

add dividers

* Move Consul out of Integrations; move namespaces to govern

* move integrations/vault to secure/vault; delete integrations

* move ref arch to docs; rename Deploy Nomad back to Install Nomad

* address feedback

* linkcheck fixes

* Fixed raw_exec redirect

* add info from /nomad/tutorials/manage-jobs/jobs

* update page content with newer tutorial

* link updates for architecture sub-folders

* Add redirects for removed section index pages. Fix links.

* fix broken links from linkcheck

* Revert to use dev-portal main branch instead of nomadIA branch

* build workaround: add intro-nav-data.json with single entry

* fix content-check error

* add intro directory to get around Vercel build error

* workound for emtpry directory

* remove mdx from /intro/ to fix content-check and git snafu

* Add intro index.mdx so Vercel build should work

---------

Co-authored-by: Tu Nguyen <im2nguyen@gmail.com>
2025-07-08 19:24:52 -05:00

114 lines
4.4 KiB
Plaintext

---
layout: docs
page_title: nomad var put reference
description: |-
The `nomad var put` command creates or updates a Nomad variable.
---
# `nomad var put` command reference
The `var put` command creates or updates an existing [variable][].
## Usage
```plaintext
nomad var put [options] <variable spec file reference> [<key>=<value>]...
nomad var put [options] <path to store variable> [<variable spec file reference>] [<key>=<value>]...
```
Variable metadata and items can be supplied using a [variable
specification][varspec], by using command arguments, or by a combination of the
two techniques. An entire variable specification can be provided to the command
via standard input (stdin) by setting the first argument to "-" or from a file
by using an @-prefixed path to a variable specification file. When providing
variable data via stdin, you must provide the `-in` flag with the format of the
specification, which must be either "hcl" or "json".
Items to be stored in the variable can be supplied using the specification, as a
series of key-value pairs, or both. The value for a key-value pair can be a
string, an @-prefixed file reference, or a '-' to get the value from stdin. Item
values provided from file references or stdin are consumed as-is with no
additional processing and do not require the input format to be specified.
Values supplied as command line arguments supersede values provided in any
variable specification piped into the command or loaded from file. If ACLs are
enabled, this command requires the `variables:write` capability for the
destination namespace and path. See the [ACL policy][] documentation for
details.
## Restrictions
Variable paths are restricted to [RFC3986][] URL-safe characters that don't
conflict with the use of the characters `@` and `.` in template blocks. This
includes alphanumeric characters and the special characters `-`, `_`, `~`, and
`/`. Paths may be up to 128 bytes long. The following regex matches the allowed
paths: `^[a-zA-Z0-9-_~/]{1,128}$`
The keys for the items in a variable may contain any character, but keys
containing characters outside the set of Unicode letters, Unicode digits, and
the underscore (`_`) can not be read directly using dotted references in Nomad's
template engine. Instead, they require the use of the `index` template function
to directly access their values. This does not impact cases where the keys and
values are read using the `range` function.
Variable items are restricted to 64KiB in size. This limit is calculated by
taking the sum of the length in bytes of all of the unencrypted keys and values.
## Options
- `-check-index` `(int: <unset>)`: If set, the variable is only acted upon if
the server-side version's index matches the provided value. When a variable
specification contains a modify index, that modify index is used as the
check-index for the check-and-set operation and can be overridden using this
flag.
- `-force`: Perform this operation regardless of the state or index of the
variable on the server-side.
- `-in` `(enum: hcl | json)`: Parser to use for data supplied via standard input
or when the variable specification's type can not be known using the file
extension. Defaults to "json".
- `-out` `(enum: go-template | hcl | json | none | table)`: Format to render
created or updated variable. Defaults to "none" when stdout is a terminal and
"json" when the output is redirected.
- `-template` `(string: "")`: Template to render output with. Required when
format is "go-template", invalid for other formats.
- `-verbose`: Provides additional information via standard error to preserve
standard output (stdout) for redirected output.
- `-ui`: Open the variable page in the browser.
## Examples
Writes the data to the path "secret/creds":
```shell-session
$ nomad var put secret/creds passcode=my-long-passcode
```
The data can also be consumed from a file on disk by prefixing with the "@"
symbol. For example, you can store a variable using a specification created with
the `nomad var init` command.
```shell-session
$ nomad var put secret/foo @spec.nv.json
```
Or it can be read from standard input using the "-" symbol:
```shell-session
$ echo "abcd1234" | nomad var put secret/foo bar=-
```
## General options
@include 'general_options.mdx'
[variable]: /nomad/docs/concepts/variables
[varspec]: /nomad/docs/other-specifications/variables
[ACL Policy]: /nomad/docs/other-specifications/acl-policy#variables
[RFC3986]: https://www.rfc-editor.org/rfc/rfc3986#section-2