The run, plan, and render commands can fetch variable values from external systems at render time using the --var-source flag.
Supported source types (determined by URL scheme):
- Consul KV:
consul://<host:port>/<path> (Variables are read from <path>/<variable-name>). - Vault KV v2:
vault://<host:port>/<mount>/<path> (Variables are fields of the secret at <mount>/<path>). - Nomad Variables:
nomad://<host:port>/<path> (Variables are items in the Nomad Variable at <path>).
If the host is omitted (e.g., consul:///path), Nomad Pack uses standard environment configuration (address and token) for that tool. For Unix sockets, use unix:// and set the appropriate environment variable (e.g., NOMAD_ADDR).
Precedence (Highest to Lowest):
--var-f/--var-file- Environment variables
--var-source- Pack variable defaults
# Using multiple external sources
nomad-pack run hello_world \
--var-source consul://localhost:8500/nomad-pack \
--var-source vault://localhost:8200/secret/nomad-pack \
--var-source nomad://localhost:4646/nomad-pack
# Using standard environment config (no host specified)
nomad-pack run hello_world --var-source consul:///nomad-pack
# Using a Unix socket for Nomad
NOMAD_ADDR=unix:///secrets/api.sock \
nomad-pack run hello_world --var-source nomad:///nomad-pack