Archive for January 28th, 2014

Puppet oddities

Tuesday, January 28th, 2014

I just noticed some strange Puppet behaviour. Take a look at this:

class monitoring {
  define nrpe_command (
    $ensure               = present,
    $target               = "/etc/nagios/nrpe.d/$title.cfg"
  ) {
    file { $target :
      ensure            => file,
      owner             => root,
      group             => root,
      mode              => 0755,
      content           => "command[$title]=$command\n",
class puppet {
  monitoring::nrpe_command {"restart_puppet":
    command => "/etc/init.d/puppet restart"

This is the resulting I’ve got:

testhost:/etc/nagios/nrpe.d# ls
testhost:/etc/nagios/nrpe.d# cat puppet.cfg

Somehow, puppet eats everything until the last underscore in the $title variable when using it in the file title, but not when using the variable as content for that file.

Any ideas?