* switches JSON and HCL2 tabs for all provisioners * corrects `packer` to `Packer` * corrects `http` to `HTTP` * corrects typos and highlighting consistency issues * corrects typos and highlighting consistency issues * corrects typos and highlighting consistency issues * `ansible` -> `Ansible` * `packer fmt` for HCL2 blocks in provisioners * linting and spelling * fixes formatting * fixes formatting * Update website/content/docs/provisioners/ansible.mdx Co-authored-by: Adrien Delorme <azr@users.noreply.github.com> * fixes formatting * improves example * generate stuff Co-authored-by: Adrien Delorme <azr@users.noreply.github.com>
57 lines
2.2 KiB
Plaintext
57 lines
2.2 KiB
Plaintext
---
|
|
description: |
|
|
The `packer validate` Packer command is used to validate the syntax and
|
|
configuration of a template. The command will return a zero exit status on
|
|
success, and a non-zero exit status on failure. Additionally, if a template
|
|
doesn't validate, any error messages will be outputted.
|
|
page_title: packer validate - Commands
|
|
---
|
|
|
|
# `validate` Command
|
|
|
|
The `packer validate` Packer command is used to validate the syntax and
|
|
configuration of a [template](/docs/templates). The command will
|
|
return a zero exit status on success, and a non-zero exit status on failure.
|
|
Additionally, if a template doesn't validate, any error messages will be
|
|
outputted.
|
|
|
|
Example usage:
|
|
|
|
```shell-session
|
|
$ packer validate my-template.pkr.hcl
|
|
Template validation failed. Errors are shown below.
|
|
|
|
Errors validating build 'vmware'. 1 error(s) occurred:
|
|
|
|
* Either a path or inline script must be specified.
|
|
```
|
|
|
|
## Options
|
|
|
|
- `-syntax-only` - Only the syntax of the template is checked. The
|
|
configuration is not validated.
|
|
|
|
- `-except=foo,bar,baz` - Validates all the builds except those with the
|
|
comma-separated names. In legacy JSON templates, build names default to the
|
|
types of their builders (e.g. `docker` or
|
|
`amazon-ebs` or `virtualbox-iso`, unless a specific `name` attribute is
|
|
specified within the configuration. In HCL2 templates, the "name" is the
|
|
source block's "name" label, unless an in-build source definition adds the
|
|
"name" configuration option.
|
|
|
|
- `-only=foo,bar,baz` - Only validate the builds with the given comma-separated
|
|
names. In legacy JSON templates, build names default to the
|
|
types of their builders (e.g. `docker` or
|
|
`amazon-ebs` or `virtualbox-iso`, unless a specific `name` attribute is
|
|
specified within the configuration. In HCL2 templates, the "name" is the
|
|
source block's "name" label, unless an in-build source definition adds the
|
|
"name" configuration option.
|
|
|
|
- `-machine-readable` Sets all output to become machine-readable on stdout.
|
|
Logging, if enabled, continues to appear on stderr.
|
|
|
|
- `-var` - Set a variable in your Packer template. This option can be used
|
|
multiple times. This is useful for setting version numbers for your build.
|
|
|
|
- `-var-file` - Set template variables from a file.
|