All the Puppet manifests, public shared modules, site modules, and (Hiera) data are the code and data we create. We need tools and workflows to manage them.
In this chapter, we are going to review the existing tools and techniques to manage Puppet's code workflow, from when it is written to when it is deployed to production.
Most of the people in the Puppet world use Git to version their code, so we will refer mostly to Git, but similar processes can be followed if we manage our code with subversion, mercurial, or any other source code management tool.
In this chapter, we give an overview of the tools that can help us with our Puppet code. We will cover the following topics:
Each of us has a favorite tool for code writing. It may change according to the language we are using, our familiarity with the software or a preference of the moment.
Whatever tool we use, it should make our experience as smooth, productive, and enjoyable as possible.
I am a Vim guy, without being a guru. Having a system admin background, grown with bread and shell, I am comfortable with the possibility of using the same tool, wherever I am, on the local terminal or the remote SSH session: more or less we can expect to find Vim on any system under our keyboard.
A developer, I guess, may feel more comfortable with a tool that runs on his computer and can greatly enhance the writing experience, with syntax checks, cross references, and all the power of an IDE.
For this, there is Geppetto, a full-featured IDE, based on Eclipse and dedicated to Puppet code. Other popular editors also have Puppet plugins that can be quite useful.
The good news is that all of them can make life more enjoyable and productive when we write Puppet code.
Geppetto (http://puppetlabs.github.io/geppetto/) is one of the tools of reference for writing Puppet code. It is an open source software by Puppet Labs, which is a result of the acquisition of the startup Cloud smith that developed it.
We can install Geppetto as a standalone application or as an Eclipse plugin, if we are already using it.
It has very useful features such as:
When we launch it, we are prompted for a directory from which to create our Geppetto workplace. In a workplace, we can create projects that most of the time are modules we can directly import from the Forge or a SCM repository.
Geppetto may be memory hungry with large projects; if we bump into Internal Error: Java heap space
, we probably have to enlarge the memory pools for the JVM Geppetto runs into. In geppetto.ini
(or eclipse.ini
if we use Geppetto as a plugin), we can set something like this:
-XX:MaxPermSize=256m
-vmargs
-Xms384m
-Xmx512m
If we have to think about an evergreen tool that has accompanied many sys admins' keyboards for many years, I think that Vim is one of the first names that comes to mind.
Its power and flexibility is also well expressed in how it can be made to manage Puppet code effectively.
There are two Vim bundles that are particularly useful for us:
To install them easily we need to install Pathogen (a Vim extension that allows easy management of plugins) by copying the ~/.vim/autoload/pathogen.vim
file from https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim.
Then, be sure to have Pathogen installed in the ~/.vimrc
of our home directory:
call pathogen#infect() syntax on filetype indent plugin on
Once we have Pathogen loaded, we can easily add bundles in the .vim/bundle
directory:
git clone git://github.com/rodjek/vim-puppet.git .vim/bundle/puppet git clone git://github.com/scrooloose/syntastic.git .vim/bundle/syntastic
Now, we can use Vim with these powerful plugins that make coding with Puppet DSL definitively more comfortable.