Fun with Puppet Development Kit (pdk)

When the Puppet Development Kit was released, I was fairly skeptical.  It seemed like one of those.. “lets put out a new tool that does exactly the same thing we could already do”.  However, after spending some time with it, and especially after a recent feature that was added, I’ve grown to love it.

First and foremost, gone are the days of having to install 80 bagillion ruby gems to run linting, validation, etc tests on your puppet modules.  pdk bundles everything it needs into one convenient little pod.  That alone is a wonderful thing to have.  In the past (especially before puppet-agent was also a bundled thing), I ran into a lot of conflicts between keeping ruby gems up to date while also not hosing the real puppet agent installed on the machine.

Recently they added an amazing feature called pdk convert.  (Read more at the official site here: https://puppet.com/blog/guide-converting-module-pdk)  Used by default, it adapts your module as best it can to good standards and adds quite a few files to make sure your module can be validated, do simple unit tests, and prepares it to be used with continuous integration systems (like TravisCI or AppVeyor — which admittedly doesn’t help us much with local modules right now).  It also is a great way to make your .gitignore and other assorted housekeeping type files consistent.

What I found even more interesting about the feature though is that you can fork their upstream template locally and make whatever modifications you need!  For example, we run Jenkins and the method we are using for configuring how a module is tested is to include a Jenkinsfile in each module.  We were able to easily add that to our own version of the template, while keeping the ability to merge upstream when Puppet themselves add new things.  Within the course of a couple of days I was able to get all of our 20+ internal modules validating and running some rudimentary unit tests, as well as our control repo (which I had to sort of treat like a module mind you).  There’s still a lot to be done, but pdk made it all quite easy — and I didn’t have to fight with my actual host to get things going like I normally do.

If you can work it into your workflow, you can use pdk to create all of your classes, defines, etc — where it places a handy little stub, but also creates a bare unit test to start with for everything you create.  I haven’t quite worked that into my workflow, but still pretty cool.

They plan on adding quite a bit more functionality to it over time — so I’m excited to see what they come up with. =)  I highly recommend checking it out when you get a chance.  The easiest way to start would be to:

  1. install pdk
  2. take one of your existing modules
  3. pdk convert
  4. pdk validate
  5. pdk test unit

And see what comes of it.  =)