Hi all,
I'm using hiera with puppet to create Nagios contacts. However, it seems
that Nagios contacts do not get put into multiple contact groups. No
errors are thrown, but I think this is wrong.
After running the below code the contact "jg4461" is only placed in the
"resnet" contactgroup (see bottom). Is this expected behaviour?
Puppet expects a comma-delimited string of contact group names (as will appear in the target config file) rather than an array. Upon receiving an array, it somehow chooses just one of its elements.
On 13/01/14 23:00, jcbollinger wrote:
Puppet expects a comma-delimited string of contact group names (as will appear in the target config file) rather than an array. Upon receiving an array, it somehow chooses just one of its elements.
It seems your second suggestion was correct. The nagios_* types expect a comma-separated string, not an array.
This is ridiculous and bizarre behaviour and seems to defy the whole point of having a managed resource, and there is an old, open bug for it.
http://projects.puppetlabs.com/issues/4020
There's a workaround using templates as a filthy hack:
# manifest.pp
nagios_host { "$fqdn":
address => "$ipaddress",
hostgroups => template("join_hostgroups.erb")
}
On Tuesday, January 14, 2014 5:42:54 AM UTC-6, Jonathan Gazeley wrote:
This is ridiculous and bizarre behaviour and seems to defy the whole point of having a managed resource, and there is an old, open bug for it.
http://projects.puppetlabs.com/issues/4020
I think "ridiculous and bizarre" is a bit strong. It's strange that the type selects one element and ignores the rest, but it's not so surprising that's what's wanted in the first place is whatever string is supposed to be plugged in to the corresponding hole in the Nagios config file. That's even a viable way to read the documentation for the type. And I certainly don't understand what any of this has to do with "the whole point of having a managed resource".
There's a workaround using templates as a filthy hack:
# manifest.pp
nagios_host { "$fqdn":
address => "$ipaddress",
hostgroups => template("join_hostgroups.erb")
}
You seem angry about this. I don't understand why.
Anyway, if you have Puppetlabs's "stdlib" add-in module installed, then it provides a join() function that can replace the template. Or at minimum it would probably be better to use an inline_template() instead of an external one.