Is there a way to communicate information between classes/resources?
I have a profile that I want to include on all nodes to set them up as being monitored by Icinga which uses an exported resource :
class profile::icinga2::host {
@@::icinga2::object::host { $::fqdn:
display_name => $::fqdn,
address => $::ipaddress,
vars => hiera_hash('icinga_vars',{}) + {
"dns_lookup" => $::fqdn,
"dns_expected_answers" => $::ipaddress,
},
target => "/etc/icinga2/conf.d/puppet.d/${::fqdn}.conf"
}
}
These resources are then declared in the icinga server using the resource collector:
<<| icinga2::object::host|>>
I want to be able to customize the vars entry in the profile::icinga2::host resource and at the moment doing by adding icinga_vars data into the hiera yaml file for the node e.g.:
icinga_vars:
http_uri: "http://puppetboard.zoo.lan"
However ideally I would do this inside any classes that are included by the node itself.
Is there a way of setting up data in classes that can then be read by a different class?
Facts don’t seem the right way of doing it and nor does puppetdb, is there an alternative?
Can I, for example, create a icinga2::variable class and declare those outside the profile::icinga2::host class and then iterate over them in the profile::icinga2::host class? How would that be done and how would dependencies be handled e.g. I would need to ensure the icinga2::variables are ready to be read by profile::icinga2::host Thanks
0 Answers