Skip to content

Command line tool for bulk syntax validation of puppet '.pp' files.

Notifications You must be signed in to change notification settings

xraystyle/puppet-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 

Repository files navigation

Bulk Puppet File Validator

Any Puppet file or manifest with the extension '.pp' can be validated with the command puppet parser validate $file. The validator checks for valid puppet syntax, and returns an error with a line number if validation fails.

Best practice is to validate each puppet file after any edits are made before deployment to cut down on the number of errors, but this can become tedious if a large number of files are edited, or if the puppet codebase is large.

This tool validates '.pp' files in batches, depending on command line options.

Save it somewhere in your $PATH and make it executable.

Examples:

Validate every '.pp' file in the current directory and all subdirectories:

modules $: validate-pp -a
Validating /etc/puppetlabs/puppet/modules/base/manifests/init.pp...
Validating /etc/puppetlabs/puppet/modules/base/manifests/ssh.pp...
Validating /etc/puppetlabs/puppet/modules/base/manifests/sudoers.pp...
Validating /etc/puppetlabs/puppet/modules/base/tests/init.pp...
Validating /etc/puppetlabs/puppet/modules/base/tests/ssh.pp...
Validating /etc/puppetlabs/puppet/modules/base/tests/sudoers.pp...
Validating /etc/puppetlabs/puppet/modules/localusers/manifests/groups/finance.pp...
Validating /etc/puppetlabs/puppet/modules/localusers/manifests/groups/wheel.pp...
Validating /etc/puppetlabs/puppet/modules/localusers/manifests/init.pp...
Validating /etc/puppetlabs/puppet/modules/localusers/tests/init.pp...
No errors found, all parsed files appear valid.

Validate only the files that have been added, edited, copied, or moved according to git:

### This is significantly faster than checking every file,
### especially as the codebase increases in size.

modules $: git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

  modified:   base/manifests/ssh.pp

Untracked files:
  (use "git add <file>..." to include in what will be committed)

  base/manifests/httpd.pp

no changes added to commit (use "git add" and/or "git commit -a")
modules $: validate-pp -g
Validating /etc/puppetlabs/puppet/modules/base/manifests/ssh.pp...
Validating /etc/puppetlabs/puppet/modules/base/manifests/httpd.pp...
No errors found, all parsed files appear valid.

Try validate-pp --help for the full list of options.

About

Command line tool for bulk syntax validation of puppet '.pp' files.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages