Friends don’t let friends commit puppet code with obvious errors. Especially when you’re working with a team, having a consistent style enforced by something like puppet-lint means less messy diffs as you send changes to each other to review. And if you’re leveraging stuff like r10k, you definitely don’t want that screwed up, where the rubber meets the road.
Here’s a way to use one of the more popular collection of puppet-specific hooks to add checks before you commit locally across the modules you maintain and deploy.
First, for consistencies sake, you probably want to make sure you have a consistent directory in your home folder to point at. If you don’t have one already, you can create a binary directory to store stuff like csshX, munkipkg, and other fun items that you want in your path.
mkdir bin
chmod 700 bin
chmod +a "group:everyone deny delete" bin
(if you want to add it to your path temporarily, you’d run PATH=$PATH:~/bin
or add it on each login by creating or appending ~/.bash_profile
with the following export PATH=${PATH}:~/bin
)
Download the current master version of the code here https://github.com/drwahl/puppet-git-hooks/archive/master.zip and unpack it into that bin directory.
Now in case you haven’t had the pure unadultered joy, it’s time to have fun with ruby via bundler and all of the things you’re actually going to perform the checks with:
sudo gem install -n /usr/local/bin bundler r10k rspec puppet-lint
avoids the default gem install behavior of trying to write to SIP-protected directories cd ~/bin/puppet-git-hooks-master/
bundle install --path vendor/bundle
Now you just go to the git repo directory you’re hoping to lint or perform pre-commit checks on and run the following: ln -s ~/bin/puppet-git-hooks-master/pre-commit .git/hooks/pre-commit
Recent Comments