A collection of task oriented solutions in Puppet

 

Syntax check your EPP templates

Challenge

Check your Embedded Puppet (EPP) templates for syntax errors

Solution

# Invalid EPP template - note the missing | in the first line
<%- | Hash $project_details -%>
<project>
  <description><%= $project_details['description'] %></description>
</project>
# to syntax check it we run
puppet epp validate broken.epp

# and we get -
Error: Syntax error at '<project>
  <description>' at broken.epp:1:32
Error: Errors while validating epp
Error: Try 'puppet help epp validate' for usage

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

Explanation

Finding a mistake in your Embedded Puppet (EPP) templates when you're developing them is much nicer than finding it when agents start checking in for their configs. If you're writing EPP templates you should be testing them as early in the process as possible. By using the puppet epp validate command as you work, and before committing and pushing your code, you can catch a raft of issues before they can cause any failures.

It is worth noting that puppet epp validate only provides a basic syntax check, it won't find misspelled properties or logic errors in your templates.

See also