> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Dynamic Configuration and Nomad Variables

> Using Nomad Variables and templates to manage non-secret runtime configuration and reload apps without redeploying, contrasted with Vault for secret lifecycle management

A support ticket arrived: a customer's 40 MB export was rejected. The culprit was a single number — an upload limit — baked into a configuration file inside Tidepool’s container image. Changing that number required editing the file, rebuilding the image, pushing it, and rolling out every API instance: twenty minutes of CI/CD just to update one value.

So why was that number inside the image? When Maya first containerized the app, putting configuration in the image was straightforward. That works until values need to change more often than code.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/l4I9ipyyKXTd2i-D/images/Learn-By-Doing-HashiCorp-Nomad/Operating-Nomad-Day-to-Day/Dynamic-Configuration-and-Nomad-Variables/deployment-workflow-40mb-export-rejected.jpg?fit=max&auto=format&n=l4I9ipyyKXTd2i-D&q=85&s=221d4a4ffa5c2c83429be830306fc5d1" alt="A presentation slide showing a deployment workflow with icons for &#x22;edit,&#x22; &#x22;rebuild,&#x22; &#x22;push,&#x22; and &#x22;twenty minutes&#x22; and the text &#x22;A 40 MB export, rejected.&#x22; Below are Docker whale icons and server boxes labeled box-1 through box-4 with check marks." width="1920" height="1080" data-path="images/Learn-By-Doing-HashiCorp-Nomad/Operating-Nomad-Day-to-Day/Dynamic-Configuration-and-Nomad-Variables/deployment-workflow-40mb-export-rejected.jpg" />
</Frame>

Maya could have stored the limit in Vault — Tidepool already integrated Vault — and fetched it from the template at runtime. But Vault is designed to manage credentials: issuing ephemeral secrets, rotating them, leasing them, and auditing access. That’s powerful but heavyweight for a non-secret numeric limit, and it creates an additional operational dependency.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/l4I9ipyyKXTd2i-D/images/Learn-By-Doing-HashiCorp-Nomad/Operating-Nomad-Day-to-Day/Dynamic-Configuration-and-Nomad-Variables/vault-too-much-export-rejected.jpg?fit=max&auto=format&n=l4I9ipyyKXTd2i-D&q=85&s=a3d67820d2415c237c7a9a5c804c8809" alt="A presentation slide titled &#x22;Vault Is Too Much for This&#x22; showing a yellow inverted triangle labeled &#x22;expiry, rotation, audit&#x22; and the text &#x22;A 40 MB export, rejected.&#x22; Along the bottom are four server illustrations with Docker whale icons labeled box-1 through box-4." width="1920" height="1080" data-path="images/Learn-By-Doing-HashiCorp-Nomad/Operating-Nomad-Day-to-Day/Dynamic-Configuration-and-Nomad-Variables/vault-too-much-export-rejected.jpg" />
</Frame>

Nomad provides a simpler, built-in option: Nomad Variables. They are encrypted configuration values stored in Nomad’s state store, replicated across Nomad servers, and governed by the same ACL rules — no separate cluster required.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/l4I9ipyyKXTd2i-D/images/Learn-By-Doing-HashiCorp-Nomad/Operating-Nomad-Day-to-Day/Dynamic-Configuration-and-Nomad-Variables/nomad-variables-encrypted-at-rest-docker-deploy.jpg?fit=max&auto=format&n=l4I9ipyyKXTd2i-D&q=85&s=7bc9ac4154f86f8a86b9ba4f00de7c74" alt="A presentation slide titled &#x22;Nomad Variables&#x22; showing icons for a built-in database and an encrypted-at-rest padlock with the caption &#x22;Nothing extra to install.&#x22; Below are Docker whale icons and four labeled server boxes (box-1 to box-4) illustrating deployment." width="1920" height="1080" data-path="images/Learn-By-Doing-HashiCorp-Nomad/Operating-Nomad-Day-to-Day/Dynamic-Configuration-and-Nomad-Variables/nomad-variables-encrypted-at-rest-docker-deploy.jpg" />
</Frame>

Example — create the variable at a path that reflects job/group/task:

```bash theme={null}
$ nomad var put nomad/jobs/tidepool-api/api/server
upload_limit=50MB
Created variable "nomad/jobs/tidepool-api/api/server"
$ nomad var get nomad/jobs/tidepool-api/api/server
upload_limit=50MB
```

Why that path? Reading it backwards — `server` (task), `api` (group), `tidepool-api` (job) — makes the variable’s scope and ownership obvious. Nomad grants a task read and list access to variables under its own path automatically; you don’t need an extra ACL rule for that. The API can read its own configuration, cannot read the CSV worker’s, and cannot read another team’s. The path is the permission boundary.

To inject the variable into the running app, use a Nomad template block. The template mechanism is the same one used for secrets and other dynamic values: the `nomadVar` function fetches the variable by path and key. Nomad renders the file before the task starts and re-renders it when the variable changes, writing a plain file that the application reads.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/l4I9ipyyKXTd2i-D/images/Learn-By-Doing-HashiCorp-Nomad/Operating-Nomad-Day-to-Day/Dynamic-Configuration-and-Nomad-Variables/nomadvar-prefix-path-docker-boxes.jpg?fit=max&auto=format&n=l4I9ipyyKXTd2i-D&q=85&s=810d81103e2a60dec0d7e06267a6e481" alt="A presentation slide titled &#x22;nomadVar in a Template&#x22; showing a folder and shield icon with the caption &#x22;the path is the rule its own prefix&#x22; and the bold text &#x22;Its own prefix, and nothing else.&#x22; Below are four server/container illustrations with Docker whale icons labeled box-1 through box-4." width="1920" height="1080" data-path="images/Learn-By-Doing-HashiCorp-Nomad/Operating-Nomad-Day-to-Day/Dynamic-Configuration-and-Nomad-Variables/nomadvar-prefix-path-docker-boxes.jpg" />
</Frame>

A typical template snippet that writes the variable into a config file and uses signaling to reload the app (instead of restarting it) looks like this:

```hcl theme={null}
template {
  destination    = "local/config/tidepool-api.conf"
  change_mode    = "signal"
  change_signal  = "SIGHUP"

  data = <<EOH
upload_limit = "{{ nomadVar "nomad/jobs/tidepool-api/api/server" "upload_limit" }}"
EOH
}
```

Because `change_mode` is set to `"signal"`, when the variable updates Nomad rewrites the file and sends the configured signal to the running process. For configuration-only changes, signaling avoids unnecessary restarts: there’s no need to restart three API instances just to update a single numeric limit.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/l4I9ipyyKXTd2i-D/images/Learn-By-Doing-HashiCorp-Nomad/Operating-Nomad-Day-to-Day/Dynamic-Configuration-and-Nomad-Variables/signal-not-restart-docker-boxes.jpg?fit=max&auto=format&n=l4I9ipyyKXTd2i-D&q=85&s=c1ca948a01618eea7eece8efade026eb" alt="A presentation slide titled &#x22;signal, Not Restart&#x22; that shows icons for a template and an ordinary config file with the caption &#x22;The app reads an ordinary file.&#x22; Below are four Docker whale icons above server illustrations labeled box-1 through box-4, each marked with a green check." width="1920" height="1080" data-path="images/Learn-By-Doing-HashiCorp-Nomad/Operating-Nomad-Day-to-Day/Dynamic-Configuration-and-Nomad-Variables/signal-not-restart-docker-boxes.jpg" />
</Frame>

The application must support reloading its configuration on the chosen signal (many do). The workflow is simple:

* Maya updates the variable with `nomad var put`.
* Nomad re-renders the template and writes the updated config file.
* Nomad sends the configured signal (e.g., `SIGHUP`) to the process.
* The process reloads the new `upload_limit` and the next upload succeeds — no rebuild, no pipeline, no redeploy.

You can inspect the current value and see when it last changed with `nomad var get`.

When to use Nomad Variables vs Vault

* Use Nomad Variables for non-secret configuration you want to change without shipping code: limits, feature flags, timeouts, or endpoints.
* Use Vault when you require credential lifecycle management: rotation, expiry, leases, and detailed audit trails.

Comparison at a glance:

| Use Case | Recommended Tool | Why |
| - | - | - |
| Non-secret runtime config (limits, flags, timeouts) | Nomad Variables | Stored in Nomad’s state store, ACL-protected, re-render templates, no extra infrastructure |
| Credentials that need rotation/leases | Vault | Issues ephemeral credentials, manages rotation and expiry, provides auditable access |
| Secrets requiring strict central lifecycle controls | Vault | End-to-end secret lifecycle management and robust auditing |
| Simple, frequently changed settings for a single job | Nomad Variables | Path-based permissions and automatic access for the owning task |

See Nomad’s docs for details:

* Nomad Variables: [https://www.nomadproject.io/docs/operators/variables](https://www.nomadproject.io/docs/operators/variables)
* Nomad template stanza: [https://www.nomadproject.io/docs/job-spec/template](https://www.nomadproject.io/docs/job-spec/template)
* nomad var CLI: [https://www.nomadproject.io/docs/commands/var](https://www.nomadproject.io/docs/commands/var)

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/l4I9ipyyKXTd2i-D/images/Learn-By-Doing-HashiCorp-Nomad/Operating-Nomad-Day-to-Day/Dynamic-Configuration-and-Nomad-Variables/variables-vault-file-signal-norestart-docker.jpg?fit=max&auto=format&n=l4I9ipyyKXTd2i-D&q=85&s=c9593caa2cf3ba1243688925904b5167" alt="A presentation slide titled &#x22;Variables or Vault&#x22; showing three icons with captions — a document (&#x22;the file re-renders&#x22;), a radio tower (&#x22;the signal lands&#x22;), and a traffic light with large text &#x22;Nothing restarts.&#x22; Below are four Docker whale and server icons labeled box-1 through box-4 with check marks." width="1920" height="1080" data-path="images/Learn-By-Doing-HashiCorp-Nomad/Operating-Nomad-Day-to-Day/Dynamic-Configuration-and-Nomad-Variables/variables-vault-file-signal-norestart-docker.jpg" />
</Frame>

<Callout icon="lightbulb" color="#1CB2FE">
  Use Nomad Variables for non-secret configuration that you want to update without redeploying. Use Vault when you need rotation, expiry, or detailed audit trails for secrets.
</Callout>

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/learn-by-doing-hashicorp-nomad/module/b579370f-3fca-4d5f-b200-462e1a84bcd2/lesson/b3a40de9-f99d-44de-bb14-f8cc01a5b93f" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.