2017-02-11 00:29:00 +00:00
|
|
|
---
|
2020-04-07 18:55:19 +00:00
|
|
|
layout: docs
|
2020-04-06 20:27:35 +00:00
|
|
|
page_title: 'Commands: Validate'
|
2020-04-13 18:40:26 +00:00
|
|
|
sidebar_title: validate
|
2017-02-11 00:29:00 +00:00
|
|
|
description: >
|
2020-04-07 18:55:19 +00:00
|
|
|
The `consul validate` command tests that config files are valid by attempting
|
|
|
|
to parse them. Useful to ensure a configuration change will not cause consul
|
|
|
|
to fail after a restart.
|
2017-02-11 00:29:00 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# Consul Validate
|
|
|
|
|
2017-10-20 01:59:05 +00:00
|
|
|
The `consul validate` command performs a thorough sanity test on Consul
|
|
|
|
configuration files. For each file or directory given, the command will
|
|
|
|
attempt to parse the contents just as the `consul agent` command would,
|
|
|
|
and catch any errors.
|
|
|
|
|
|
|
|
This is useful to do a test of the configuration only, without actually
|
|
|
|
starting the agent. This performs all of the validation the agent would, so
|
|
|
|
this should be given the complete set of configuration files that are going
|
|
|
|
to be loaded by the agent. This command cannot operate on partial
|
|
|
|
configuration fragments since those won't pass the full agent validation.
|
2017-02-11 00:29:00 +00:00
|
|
|
|
|
|
|
For more information on the format of Consul's configuration files, read the
|
2020-04-09 23:46:54 +00:00
|
|
|
consul agent [Configuration Files](/docs/agent/options#configuration-files)
|
2017-02-11 00:29:00 +00:00
|
|
|
section.
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
Usage: `consul validate [options] FILE_OR_DIRECTORY...`
|
|
|
|
|
|
|
|
Returns 0 if the configuration is valid, or 1 if there are problems.
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2017-02-11 00:29:00 +00:00
|
|
|
$ consul validate /etc/consul.d
|
|
|
|
Configuration is valid!
|
|
|
|
```
|