Syntax checks for Puppet manifests, templates, and Hiera YAML.
This should work on any version of:
- Puppet >= 2.7 that provides the
validate
face. - Ruby >= 1.8 with
erb
from stdlib.
You can see the matrix of specific versions that we currently test against in the TravisCI config.
Include the following in your Rakefile
:
require 'puppet-syntax/tasks/puppet-syntax'
Test all manifests and templates relative to your Rakefile
:
➜ puppet git:(master) bundle exec rake syntax
---> syntax:manifests
---> syntax:templates
---> syntax:hiera:yaml
A non-zero exit code and error message will be returned for any failures:
➜ puppet git:(master) bundle exec rake syntax
---> syntax:manifests
rake aborted!
Could not parse for environment production: Syntax error at end of file at demo.pp:2
Tasks: TOP => syntax => syntax:manifests
(See full trace by running task with --trace)
Use in conjunction with lint and spec tests for Continuous Integration:
task :test => [
:syntax,
:lint,
:spec,
]
Paths can be excluded with:
PuppetSyntax.exclude_paths = ["vendor/**/*"]
Add this line to your application's Gemfile:
gem 'puppet-syntax'
And then execute:
$ bundle
Or install it yourself as:
$ gem install puppet-syntax
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request