Validate a module

By default, the validate command runs metadata validation first, then Puppet validation, then Ruby validation. Optionally, you can validate only certain files or directories, run a specific type of validation, such as metadata or Puppet validation, or run all validations simultaneously. Additionally, you can send your validation output to a file in either JUnit or text format.

  1. From the command line, change into the module's directory with cd <MODULE_NAME>
  2. Run all validations by running pdk validate.

    You can customize unit test execution by using command-line options with PDK. Here are some common scenarios:

    pdk validate --parallel

    To validate against a specific major version of Puppet, add the --puppet-version option flag.

    For example. To validate against Puppet 7, run:

    pdk validate --puppet-version 7

    For a complete list of command options and usage information, see the PDK command reference.

Ignoring files during module validation

There are times when certain files can be ignored when validating the contents of a Puppet module. PDK provides a configuration option to list sets of files to ignore when running any of the validators.

To configure PDK to ignore a file, use pdk set config project.validate.ignore. The project.validate.ignore setting accepts multiple files. To add one or more files, run the command for each file or pattern you want to add.

For example, to ignore a file called example.yaml in the folder called config, you would run the following command:

pdk set config project.validate.ignore "config/example.yaml"

To add a wildcard, use a valid Git ignore pattern:

pdk set config project.validate.ignore "config/*.yaml"