On 01/05/14 14:18, jcbollinger wrote:
On Thursday, May 1, 2014 5:06:37 AM UTC-5, Jonathan Gazeley
wrote:
I'm
struggling a little bit with this one.
Some of my puppet nodes have lights-out management. For those
that do, I
want to put the IP address of their iLOM card in Hiera and
have that
appear as the notes_url in nagios_host{}.
This works well for hosts that *do* have iLOM, but for those
with no
Hiera variable called ilom I don't want notes_url to be
defined at all.
Setting notes_url => undef doesn't work because it is still
written out
in the nagios config and the url appears clickable, but with
no link
behind it.
Can you present some example code?
Thanks for your long and detailed response, that's extremely
helpful. So far I've tried these ways:
@@nagios_host { $::fqdn:
ensure => present,
address => $::ipaddress,
action_url => "/nagios/pnp4nagios/graph?host=${::fqdn}",
notes_url => hiera('ilom', absent),
}
or
@@nagios_host { $::fqdn:
ensure => present,
address => $::ipaddress,
action_url => "/nagios/pnp4nagios/graph?host=${::fqdn}",
notes_url => hiera('ilom', undef),
}
or
$ilom = hiera('ilom', undef)
@@nagios_host { $::fqdn:
ensure => present,
address => $::ipaddress,
action_url => "/nagios/pnp4nagios/graph?host=${::fqdn}",
notes_url => $ilom,
}
The second and third ways "work" in that an undef value is written
into the nagios config, which is valid. However when notes_url has
an undef value the clickable icon still appears in nagios but has no
link associated - which is why I'd like to be able to set notes_url
to undef or absent, and have the icon not appear in nagios unless
there is a non-blank value.
So I guess there are really two questions. Having seen your examples
of defined types helps me understand how to handle this in puppet.
But I think my main problem is that there isn't a way to cause
action_url to be absent unless it is not mentioned at all in the
@@nagios_host resource at all. It seems the only way to work around
this is to have a defined type like this, but there is duplication.
define site::managd_host ($ilom_ip = undef) {
if $ilom_ip {
# Nagios_host with ilom parameter in notes_url
@@nagios_host { $::fqdn:
ensure => present,
address => $::ipaddress,
action_url => "/nagios/pnp4nagios/graph?host=${::fqdn}",
notes_url => $ilom_ip,
}
} else {
# No notes_url
@@nagios_host { $::fqdn:
ensure => present,
address => $::ipaddress,
action_url => "/nagios/pnp4nagios/graph?host=${::fqdn}",
}
}
}
Thanks,
Jonathan