Puppet and Hiera

Hi everybody,

I want add custom variables for every host that will be added to the Icingaweb2 Interface.
I want to use these custom host variables to e.g. set threshold values for specific host-checks, that have a default value and can be offset with a configuration file.

Since I am already successfully using the puppet module by voxpopuli and succeeded to implement puppet facts into Icingaweb2, I kinda know that the infrastructure is already there.

I know it is possible to take variables from puppet facts and convert them to variables / properties of nodes in Icinga2, this basically works with either Icinga2 or Icingaweb2 via the director that assigns values.
My problem is now:
How can I add custom variables from hiera files to Icingaweb2 via puppet?
On my puppet server, I have the usual hieradata structure with a hiera.yaml file for every module, a common.yaml file and the hierdata-directory with host specific information.
However I don’t know how to get custom variables into puppetdb, they don’t get implemented from the host-specific yaml files.

I am aware that this issue might leave the scope of this community. Still I hope, that someone can at least point me in the right direction, as I don’t know where to look for the issue anymore.

If there is an easier way to add per host variables via puppet to Icinga in an organized way, I am of course open to suggestions.

Thank you very much.

I’m not 100% clear what you’re asking for. You said you are already getting Puppet facts into Icinga. So if you’re essentially asking “how do I look up data from hiera?” then here is an example of how one might add arbitrary data from hiera to a host’s vars

monitoring::host::vars:
  mykey: 'myval'
  morethings: 'moredata'
$host_vars = lookup('monitoring::host::vars', {
  'value_type'    => Hash,
  'merge'         => 'first',
  'default_value' => {},
})
@@::icinga2::object::host { $::fqdn:
  # <bunch of params>
  vars          => {
    'puppetized'         => true,
    'virtual'            => $::facts['is_virtual'],
  } + $host_vars,
}