Thursday, March 8, 2012

Tip: Puppet augeas provider skips files

I was writing a Puppet class using the augeas provider and found a case where the manifest would work sometimes, but not other times, resulting in a silent error, revealed only by a debug message:
Skipping because no files were changed
I started with this, and it worked sometimes:
augeas {"automaster$name": context => "/files/etc/auto.master", changes => $changes, onlyif => "match map[. = '/$name'] size == 0" }
In some cases it did not work, saying "Skipping because no files were changed" even though debugging showed that changes were made. This version works all the time:
augeas {"automaster$name": context => "/files/etc/auto.master", incl => "/etc/auto.master", lens => "Automaster.lns", load_path => "/var/lib/puppet/lib/augeas/lenses", changes => $changes, onlyif => "match map[. = '/$name'] size == 0" }
I'm not yet sure why this happened, but it seems the difference is that in a manifest where augeas is used previously with load_path, that I need to use it here too.

Tip: Joining lists in Puppet

Tip of the day: joining lists in Puppet
node default { include test } class test { $list = ['foo','bar',undef,'4',undef,'six'] $joined = inline_template("<%= (list).reject{|x| x == :undef} %>") notify{"see $joined":} }

Another attempt...

A coworker of mine rekindled my thoughts about blogging. So, I thought I'd add a couple posts.