Happy 2013 everyone! One of my resolutions is to build some more expertise in DevOps. Puppet is the platform that I’m using in the lab, and it would be great if my text editor (vim) could understand Puppet syntax….
Out of the box, vim on Ubuntu 12.04 only keeps track of open and close brackets. If you ever used PuppetLab’s Learning Puppet VM, you’ve seen that vim can be altered to be a bit more Puppet-friendly including keyword color-coding and automated indents.
For example, instead of vim displaying your puppet code like this:
Your code can look like this:
Here is the condensed list of setup steps (follow at your own risk):
1. Make a ~/.vim directory in your home folder and copy pathogen to it:
mkdir -p ~/.vim/autoload ~/.vim/bundle
curl -Sso ~/.vim/autoload/pathogen.vim https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
2. Configure a ~/.vimrc file in your home directory that includes the following lines:
call pathogen#infect() syntax on filetype plugin indent on
3. Copy the vim-puppet module to ~/.vim/bundle in your home directory by running this command from that directory.
sudo git clone git://github.com/rodjek/vim-puppet.git
The next time that you create a Puppet Manifest file (make sure it has a .pp extension), vim will format your code according to PuppetLabs syntax standards.