Puppet: How can i check for syntax errors on my puppet code? Is there any tool to do this?

0 votes
I have written a puppet module using  puppet DSL, I need to cross check this module for any errors so that my module works efficiently. How can I validate my puppet code?
Aug 7 in Puppet by Sneha
146 views

1 answer to this question.

0 votes
  • At the lowest level of checking, you can use the Puppet parser to do syntax validation.

  • There are a couple of places where you can insert syntax validation. One method is by manually running `puppet parser validate` to make sure that the manifest can be parsed before you commit your changes or deploy them to a live environment.

  • Puppet parser lets you validate Puppet code to make sure it contains no syntax errors. It can be a useful part of your continuous integration toolchain.

For example :

Validate the default site manifest at /etc/puppetlabs/puppet/manifests/site.pp:

$ puppet parser validate

Validate two arbitrary manifest files:

$ puppet parser validate init.pp vhost.pp

For more info: https://puppet.com/docs/puppet/6.7/man/parser.html

  • In addition, you can integrate syntax checking into your editor. Vim has built in code compilation functionality that can be used to run error checking, so you can quickly validate your code and jump to sections of code with syntax errors. 

  • There are plugins like Syntastic that will do continuous checking so you're immediately alerted when syntax errors are made. 

  • There's another tool called puppet-lint that could be used to serve the purpose

answered Aug 7 by Sirajul
• 36,620 points

Related Questions In Puppet

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Puppet+Docker: How do i configure my docker container to use a NFS volume through a Hiera config file?

If using Hiera, configure the docker::volumes class in the ...READ MORE

answered Aug 14 in Puppet by Sirajul
• 36,620 points
31 views
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
209 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How can i check the requests of certificates from puppet agent to puppet master?

You could do this by executing the ...READ MORE

answered Jul 24 in Puppet by Sirajul
• 36,620 points
80 views