Using catalog-diff while refactoring Puppet code

In yesterday’s post I showed how you can compile a Puppet catalog from a bundle on a laptop.  Today I’m going to show how you can use Zack Smith’s catalog diff tool to assist with complex refactoring changes.

Code examples

For the purpose of describing how to use the catalog diff tool, it will be better to use an artificially simple code example.  Imagine we have all of our code in site.pp as follows:

node 'myhost.example.com' { file { '/tmp/myfile': ensure => file, content => "My hostname is ${::hostname}\n", } } read more

Compiling a puppet catalog – on a laptop

From time to time I have wished that I could easily compile a Puppet catalog from my laptop. Use cases that spring to mind include, "hey, wouldn't it be great if I could see what this super-complicated Puppet Forge module is actually doing without having to spin up a VM and 'puppet apply' it". Othertimes it has just been curiosity.