I solved this in a similar manner. I wrote a custom fact (which essentially returned /var/lib/puppet/state/classes.txt) and then a custom function that generated a list of hostgroups based on that.
On Wed, Jun 8, 2011 at 6:47 AM, Chris Phillips <ch...@untrepid.com> wrote: > > > On 8 June 2011 13:30, Martijn Grendelman <mart...@iphion.nl> wrote: > >> Hi, >> >> > i want to archive the following: >> > >> > i define an exported ressource for HostX to be monitored in nagios: >> > >> > @@nagios_host { $fqdn: >> > ensure => present, >> > alias => $hostname, >> > address => $ipadress, >> > use => "generic-host", >> > hostgroups => ubuntu, >> > target => $icingahostfile, >> > } >> > >> > That fine and works as expected and HostX is in hostgroup ubuntu. >> > HostX has included a class ssh which installs the ssh services and >> > configures them. Inside this class i want to define that HostX is also >> in >> > hostgroup ssh-server. >> > And another class, which puts the node in another environment => there i >> > want to define, that HostX is in hostgroup testing-server and so on. >> > How do i archive that? How must the definition inside all these classes >> > look like? >> >> That's a lot more difficult than you might expect. >> >> I recently solved it, by collecting all the necessary hostgroups for a >> host in a file using 'concat', and creating a custom fact (hostgroups) >> that joins all the lines in the hostgroups-file together, for use with >> nagios_host's hostgroups parameter. >> >> The biggest drawback is that it takes two puppet runs on the target (first >> one for populating the hostgroups-file, so that the custom fact is set >> properly on the second run) before the nagios server can collect the >> exported hosts, so it takes a while. >> >> > Well that's mad... I literally just was about to ask the exact same > question after a month of wondering... > > so where do you put this fact? Sounds like it is on the nagios "client" > side, which makes sense in terms of pulling it out, but how does it get in > there in the first place? Can you show how this file on each client is > managed? That seems to be the only bit I'm not clear on. Are you just > putting in a single word for each class? Are you at all able to manage the > class being removed from the client? Would you need to routinely purge the > file? have a initial stage class that wipes the file? > > Thanks > > Chris > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.