Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI and API SDK Configuration Files #24706

Open
schmichael opened this issue Dec 17, 2024 · 0 comments
Open

CLI and API SDK Configuration Files #24706

schmichael opened this issue Dec 17, 2024 · 0 comments

Comments

@schmichael
Copy link
Member

schmichael commented Dec 17, 2024

Proposal

As of Nomad v1.9 the CLI is only configurable via environment variables: https://developer.hashicorp.com/nomad/docs/commands#environment-variables

Allowing configuration of the CLI via a config file would not only allow for more expressive config parameters, but also be easier for generating and distributing.

Since the CLI uses the api package SDK, the api package should honor all non-CLI-flag configuration files listed below.

Parameters

  • address - Same as NOMAD_ADDR/-address
  • region - Same as NOMAD_REGION/-region
  • namespace - Same as NOMAD_NAMESPACE/-namespace
  • tls{} - Same as agent's for relevant settings
  • unsafe_skip_verify - Same as NOMAD_SKIP_VERIFY
  • cli{}
    • no_color - Same as NOMAD_CLI_NO_COLOR

Note there are no tokens or other secrets in the config file.

Mixing CLI and Agent configuration in a single file is not supported. This would encourage sharing the tls{} block between the CLI and Agent, and the CLI should not use the same certificates as the Agent.

The CLI should output a warning when encountering a config file with client{} or server{} blocks in it.

Agents should log a warning when encountering a config file with a cli{} block as this may indicate a misunderstanding or misconfiguration.

File Resolution Order

As with Nomad Agent configuration file parsing, the CLI should parse and combine multiple config files. The precedence is (so parsing should be done in reverse order):

  1. Specific CLI flags (e.g. -address)
  2. Specific environment variables (e.g. NOMAD_ADDR)
  3. -config CLI flag
  4. NOMAD_CLI_CONF environment variable
  5. .nomad.{json,hcl} in the current directory
  6. $HOME/.config/nomad/config.{json,hcl} on Unix or %APPDATA%\nomad\config.{json,hcl} on Windows

Prior Art

@jrasell did a hackweek project on CLI contexts: main...jrasell/hack-context

See also internal RFC NMD-156

External

  1. Terraform - https://developer.hashicorp.com/terraform/cli/config/config-file
  2. Packer - https://developer.hashicorp.com/packer/docs/configure
  3. kubectl - https://kubernetes.io/docs/reference/kubectl/generated/kubectl_config/

Use-cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant