Using Puppet Blacksmith
Part of tidying up my module management is automating publishing of my Forge modules. One of my biggest gripes about the Forge is that I need to go the site and do point-n-click things to update modules. That annoys me. I’d much prefer a nice simple command line interface that I can automate as part of the build process.
So I went looking for options and found Puppet Blacksmith. It’s a Ruby Gem written by the team at MaestroDev that provides some Rake tasks for automating the uploading of new Puppet module versions to the Forge. I’m going to step you through the process of installing it and adding it to your Puppet module.
Installing Puppet Blacksmith
Puppet Blacksmith is easy to install via the gem
command.
|
|
Adding Puppet Blacksmith to your module
To enable Puppet Blacksmith we need to add it to our Rakefile
. We require
it in the top of the Rakefile
like so:
|
|
You should also have the Puppet Labs spec helper installed and added to your Rakefile
too.
|
|
So now my final Rakefile
for the Sensu Puppet module looks like:
|
|
This Rakefile
provides Puppet spec testing and Puppet linting.
We also need to configure our credentials for the Forge. To do this we create a new file called .puppetforge.yml
in our home directory.
|
|
We populate that file like so:
|
|
As it has some credentials in it let’s make sure it is reasonably permissioned.
|
|
Testing Puppet Blacksmith
Adding the supporting code to our Rakefile
should enable some new Puppet Blacksmith Rake tasks. Let’s look at those new tasks now by running rake -T
.
|
|
Running Puppet Blacksmith
Now we’ve got Puppet Blacksmith installed we can use it to ship a new release of our module. Firstly, we make the required changes we want for our new releases and then commit them.
|
|
Next, we ensure we have a clean environment.
|
|
Then we increment our module version.
|
|
This will open our module’s Modulefile
, increment the version it finds inside, and then create a new commit in our project with our updated Modulefile
.
|
|
We can also tag that version if required.
|
|
We can then build our new module version.
|
|
And finally, the pièce de résistance, we can push our module to the Forge.
|
|
There’s also a handy shortcut task available that does all of this called release
.
|
|
I am really happy I’ve found Puppet Blacksmith, it makes the module release process so much easier, at least until Puppet’s module tooling supports a proper build and upload API.