host_parent param in nagios::host and hosts.erb template not working?

22 views
Skip to first unread message

Sean Alderman

unread,
Mar 31, 2014, 3:08:50 PM3/31/14
to example42-pu...@googlegroups.com
Can you give an example of how to make host_parent parameter work?

I have attempted to define from the ENC both as "host_parent" and as "nagios_host_parent"  The host's cfg file on the nagios server is never updated.

I can see the params set from the ENC yaml dump, but even with dumping a debug line into the template the result is empty.  The nagios::host define seems to not allow this parameter to be anything but ''.  Is that correct?

Template Debug:
# File Managed by Puppet
# test <%= @host_parent %>

define host{
    hostgroups     <%= @hostgroups %>
    host_name      <%= @name %>
    alias          <%= @short_alias %>
    address        <%= @ip %>
    use            <%= @use %>
<% if ! (/^(none|)$/i =~ @host_parent) then -%>
    parents        <%= @host_parent %>
<% end -%>
}


Template applied:
# File Managed by Puppet
# test

define host{
    hostgroups     all
    host_name      example.udayton.edu
    alias          example.udayton.edu
    address        example.udayton.edu
    use            generic-host
}


YAML Dump:
# /etc/puppet/node.rb example.udayton.edu
classes:
  udmonitor::client:
  udfiles:
  puppet:
  openssh:
  apache:
parameters:
  openssh_template: udfiles/openssh/openssh.erb
  puppet_monitor: "false"
  nagios_baseservices_template: udfiles/nagios/baseservices.erb
  host_parent: ta1-4510
  nagios_host_template: udfiles/nagios/host.erb
  puppi: "false"
  firewall: "false"
  foreman_env: ops
  nagios_service_template: udfiles/nagios/service.erb
  monitor: "true"
  firewall_tool: iptables
  nagios_host_parent: ta1-4510
  nagiosserver: 10.0.0.195
  monitor_tool: nagios
environment: ops


I guess its worth noting that udmonitor::client is a wrapper class that defines the nagios monitoring agent for my hosts, along with a number of other monitoring systems (like splunk and/or remote syslog).  The nrpe side of things is done simply from within udmonitor::client like so:
  class { 'nrpe':
    allowed_hosts => [ '127.0.0.1', $::ipaddress, $::nagiosserver ],
    template      => 'udfiles/nrpe/nrpe.cfg.erb',
  }

I'm hoping I can get this host_parent thing working, we've started working, and I'd be happy to make a patch to correct any issue, but at this point I just don't understand what the issue is.  Thanks!

Alessandro Franceschi

unread,
Mar 31, 2014, 4:41:21 PM3/31/14
to example42-pu...@googlegroups.com
I anticipate that I've never used the host_parent parameter but, curiously, I've to implement it, in the icinga module, in the next days for a customer of mine.
Anyway, I've given a look at the code and actually, as it is now, it will never work.
The @host_parent variable used in templates/host.erb is expected to come from the nagios::host define in  manifests/host.pp which actually has such a parameter (set as '' by default).
This define is declared in the nagios::target class and it's here where there's no mention of this parameter.
It's here the place where we have to fix the thing, adding the host_parent parameter in the nagios::host declaration.

Since the nagios::target class has to be applied to all the nodes, and can't refer/include the main nagios class (included on the nagios srver) here we should manage the host_parent as a top scope variable, as we do with other parameters.

It's not difficult, if you can wait 2/3 days I can do it, otherwise a PR is welcomed.
Reply all
Reply to author
Forward
0 new messages