Ask Your Question

Debugging puppet code

asked 2016-03-26 04:29:30 -0600

bindo gravatar image

Greetings good people,

Beginner here. Just wanted to find out as to how I'd go about debugging the puppet code? For an example if I have mistyped the code in a manifiest/template/module whats the best way to debug it in general?

Please help out gentlemen.

Many thanks in advance


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-03-26 05:46:04 -0600

updated 2016-03-26 05:46:53 -0600

I'll assume you know the fundamentals of Puppet.

  • Install the Puppet vim syntax highlighter if you're a vim user. Syntax highlighting picks up a lot of typos.

  • Set up the puppetlabs_spec_helperref.

  • Write rspec-puppet tests.

Once all this is set up:

This command will find typos in your files:

bundle exec rake validate

This command will check your code for stylistic issues:

bundle exec rake lint

This command will run your rspec-puppet tests:

bundle exec rake spec

It'll probably be quite a learning curve just to set all of this up if you're a beginner. Once you get there, however, you won't look back.

If all that's too much for you:

Check a manifest file for syntax errors:

puppet parser validate <your_file.pp>

Check an ERB file for errors:

erb -P -x -T '-' <your_file.erb> | ruby -c
edit flag offensive delete link more


I would also add using one of the IDE environments... either geppetto, or the intelliJ/Netbeans plugins for code completion, invalid syntax highlighting, and code navigation

DarylW gravatar imageDarylW ( 2016-03-26 22:27:02 -0600 )edit

Well I can't say that because I'm a vim user. :)

Alex Harvey gravatar imageAlex Harvey ( 2016-03-26 23:03:22 -0600 )edit

Thank you so much gentlemen. I will definetly try what you've suggested in my staging environment. Thanks a lot again /Bindo

bindo gravatar imagebindo ( 2016-03-27 04:43:01 -0600 )edit

If that's answered your question could you also mark the issue as resolved, thanks.

Alex Harvey gravatar imageAlex Harvey ( 2016-03-27 05:37:33 -0600 )edit

Thanks again gentlemen. Alex: Tied resolving the thread as you suggested but Im afraid that I cant seem to find the option to do so. I can close of course but it will delete the question off I reckon? Please advice.

bindo gravatar imagebindo ( 2016-04-10 20:33:33 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-03-26 04:29:30 -0600

Seen: 394 times

Last updated: Mar 26 '16