A collection of task oriented solutions in Puppet

 

Syntax check your manifests

Challenge

Check your manifests for syntax errors

Solution

# if we have this code in our manifest
# - note the missing comma after 'mode'

class broken {

  file { '/tmp/broken_resource':
    ensure => 'present',
    mode   => '0644'
    owner  => 'root',
  }

}

# to syntax check it we run
$ puppet parser validate unixdaemon/manifests/broken.pp

# and we get -
Error: Could not parse for environment production:
  Syntax error at 'owner' at /tmp/foo.pp:5:5

# check all .pp files
$ find -name '*.pp' -type f | xargs -n 1 -t puppet parser validate

Explanation

Finding a typo in your manifest when you're writing it is much better than discovering it in the puppet master logs. By syntax checking manifests as you're working, and always before a commit, you can catch some of the more obvious errors before they escape on to the network.

This is only a basic syntax check, it won't find misspelled properties or even incorrect resource names.

See also