diff --git a/.changelog/9198.txt b/.changelog/9198.txt new file mode 100644 index 000000000..139ef3b70 --- /dev/null +++ b/.changelog/9198.txt @@ -0,0 +1,3 @@ +```release-note:improvement +cli: add `nomad config validate` command to check configuration files without an agent +``` diff --git a/website/content/docs/commands/config/index.mdx b/website/content/docs/commands/config/index.mdx new file mode 100644 index 000000000..6d7a5b60d --- /dev/null +++ b/website/content/docs/commands/config/index.mdx @@ -0,0 +1,21 @@ +--- +layout: docs +page_title: 'Commands: config' +description: | + The config command interacting with configurations. +--- + +# Command: config + +The `config` command is used to interact with configurations. + +## Usage + +Usage: `nomad config [options]` + +Run `nomad config -h` for help on that subcommand. The +following subcommands are available: + +- [`config validate`][validate] - Validate configuration files + +[validate]: /docs/commands/config/validate 'Validate configuration files' diff --git a/website/content/docs/commands/config/validate.mdx b/website/content/docs/commands/config/validate.mdx new file mode 100644 index 000000000..b270541dc --- /dev/null +++ b/website/content/docs/commands/config/validate.mdx @@ -0,0 +1,51 @@ +--- +layout: docs +page_title: 'Commands: config validate' +description: | + The config validate command is used to validate Nomad configuration files. +--- + +# Command: config validate + +The `config validate` command performs validation on a set of Nomad +configuration files. This is useful to test the Nomad configuration +without starting the agent. + +## Usage + +```plaintext +nomad config validate [] +``` + +The `config validate` command requires a path to either a single +configuration file or a directory of configuration files to use for +configuring the Nomad agent. This option can be specified multiple +times. If multiple config files are passed, the values from each will +be merged together. During merging, values from files found later in +the list are merged over values from previously parsed files. + +This command cannot operate on partial configuration fragments since +those won't pass the full agent validation. This command does not +require an ACL token. + +Returns 0 if the configuration is valid, or 1 if there are problems. + +## General Options + +@include 'general_options.mdx' + +## Examples + +Validate a configuration file: + +```shell-session +$ nomad config validate ./nomad.hcl +Configuration is valid! +``` + +Validate a directory of configuration files: + +```shell-session +$ nomad config validate /etc/nomad.d +Configuration is valid! +``` diff --git a/website/data/docs-nav-data.json b/website/data/docs-nav-data.json index 9985a84d9..7a6b09ea8 100644 --- a/website/data/docs-nav-data.json +++ b/website/data/docs-nav-data.json @@ -315,6 +315,19 @@ } ] }, + { + "title": "config", + "routes": [ + { + "title": "Overview", + "path": "commands/config" + }, + { + "title": "validate", + "path": "commands/config/validate" + } + ] + }, { "title": "deployment", "routes": [