Puppet editing like a pro
Join the DZone community and get the full member experience.Join For Free
I've spent some time recently on setting up my environment to work more productively on writing puppet manifests. This blogpost highlights some of the findings to get me more productive on editing puppet files and modules. Some older information can be found at Editor Tips on the puppetlabs website.
Tip 1: Syntax highlighting,snippet completion
Puppet syntax is very specific, it's important to get clues about missing curly braces, semi-colums, etc .. as fast as possible. There is support for this in the most common editors:
@Masterzen has created a textmate bundle for use with puppet. You can find it at https://github.com/masterzen/puppet-textmate-bundle.
Michael Halligan describes how to install it from the commandline
mkdir -p /Library/Application\ Support/TextMate/Bundles cd /Library/Application\ Support/TextMate/Bundles git clone git://gitorious.org/git-tmbundle/mainline.git Git.tmbundle git clone http://git.gitorious.org/git-tmbundle/mainline.git Git.tmbundle git clone https://github.com/masterzen/puppet-textmate-bundle.git Puppet.tmbundle git clone https://github.com/drnic/Chef.tmbundle.git Chef.tmbundle osascript -e 'tell app "TextMate" to reload bundles'
If textmate is not your thing, here is how you can pimp up your vim:
When you look around for puppet/vim integration there seem to have been some re-incarnations:
- The first option is just setting the syntax of any .pp file to ruby syntax
- The second option as Garett Honeycutt describes:
- is a more elaborate version of highlighting pp files (orginally written by Luke Kanies).
- this file is distributed with puppet itself.
- Stick gaves us even more advanced tips at :
- R.I. Pienaar showed us how to use Snipmate with vim and puppet :
- His snippets can be found at http://www.devco.net/code/puppet.snippets
The most advanced vim-puppet integration I could currently(Dec/2011) find is : - the vim-puppet Tim Sharpe created. - https://github.com/rodjek/vim-puppet
To use the vim-puppet plugin, you're best to use pathogen written by Tim Pope. I've followed the instructions at http://tammersaleh.com/posts/the-modern-vim-config-with-pathogen.
I've enabled the following plugins in my update_bundles script
Most notable plugins:
- Tabular gives you automatic => alignment
- Syntastic gives you syntax feedback while you edit files
- Snipmate gives you the snippets on tab expansion
- Specky gives you functionality for rspec files
- vim-ruby gives you extra functionality for ruby files
- vim-cucumber gives you functionality for cucumber files
For more information on the vim-puppet project go to:
The snippets that are expanded in the vim-puppet plugin can be found at:
Tip 2: don't create modules structure by hand
I keep forgetting the correct structure, files etc.. when I create a new module. Luckily there is an easy way to generate a puppet module structure using the puppet-module gem
$ gem install puppet-module
puppet-module build [PATH_TO_MODULE] # Build a module for release
puppet-module changelog # Display the changelog for this tool
puppet-module changes [PATH_TO_MODULE] # Show modified files in an installed module
puppet-module clean # Clears module cache for all repositories
puppet-module generate USERNAME-MODNAME # Generate boilerplate for a new module
puppet-module help [TASK] # Describe available tasks or one specific task
puppet-module install MODULE_NAME_OR_FILE [OPTIONS] # Install a module (eg, 'user-modname') from a repositor...
puppet-module repository # Show currently configured repository
puppet-module search TERM # Search the module repository for a module matching TERM
puppet-module usage # Display detailed usage documentation for this tool
puppet-module version # Show the version information for this tool
-c, [--config=CONFIG] # Configuration file
$ puppet-module generate puppetmodule-apache
Generating module at /Users/patrick/demo-puppet/modules/puppetmodule-apache
Tip 3 - Geppetto: a Puppet IDE
The folks from cloudsmith have created an Eclipse based editor called Geppetto. It integrates the syntax highlighting, module creation etc... and has nice integration with the Puppet forge
Note: this NOT related with the Gepetto (one P) project by Alban Peignier
James Turnbull was so kind to make a quick screencast on how it works:
Geppetto tutorial from Mitch Sonies on Vimeo.
Opinions expressed by DZone contributors are their own.