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?

Undef is not a value.  You cannot store it in a variable, and assigning the 
keyword undef as a parameter value is functionally equivalent to not 
assigning any value at all.  Using undef as a parameter default 
affirmatively expresses that the parameter is optional.  My guess, then, is 
that you have something like this:

define site::managed_host($ilom_ip = undef) {
  @@nagios_host{ $title:
    notes_url => $ilom_ip,
    ....
  }
}

site::managed_host { $hostname:
  ilom_ip => undef
}

# and/or

site::managed_host { $other_hostname:
}


Indeed that won't work.  Assigning a variable reference as a parameter 
value is never the same thing as assigning undef, even if the variable has 
not been assigned a value.

 

> Setting notes_url => absent actually sets it to the string 
> 'absent'. 
>
>

Yes, Puppet DSL allows bareword strings.  You use them all the time on the 
left side of the =>, and other places.  

 

> Is there an elegant way of handling this so my iLOM-able hosts have 
> clickable iLOM links in Nagios while the non-iLOM-able hosts don't have 
> anything at all? 
>
>

I'd need to see your code.  The speculative example I present above could 
be fixed this way, though:

define site::managed_host($ilom_ip = 'NOTSET') {
  @@nagios_host{ $title:
    notes_url => $ilom_ip ? { 'NOTSET' => undef, default => $ilom_ip },
    ....
  }
}

or this way:

define site::managed_host($ilom_ip = 'NOTSET') {
  if $ilom_ip == 'NOTSET' {
    @@nagios_host{ $title:
      # no notes_url
      ....
    }
  } else {
    @@nagios_host{ $title:
      notes_url => $ilom_ip,
      ....
    }
  }
}

or in other, analogous ways.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/00c5e448-eb6e-4967-91f8-fc20d87366b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to