On Tuesday, July 16, 2013 10:52:19 PM UTC+2, Sean Alderman wrote:
Intersting... Ok, I'm out of my depth, I've not looked into Icinga and before diving into another tool I want to get to where I can build a host via Foreman and see it monitored in Nagios later. So if I could step back to the simpler concept with just the basic nagios/nrpe config.
For
the servers to be monitored - including the nagios server - Do I need
to set the nrpe_allowed_hosts to include the Nagios server, correct?
Yes, nrpe_allowed_hosts is a parameter you have to set (on all the monitored hosts) with the addess(es) of the Nagios server (and possibily add localhost and $ipaddress)
My simple experiment says yes, but throwing Foreman in the middle makes it more difficult. Should I hardcode the Nagios Server's IP? I still struggle with how parameters in your modules work
through Foreman. I have worked through some of those issues, but the
latest has to do with the nrpe_allowed_hosts parameter.
There are different approaches you can follow to integrate Example42 modules with Foreman (or generally with any other ENC) and they are related to how Example42 modules accept parameters:
- Via direct class declaration, with all the needed parameters explicitely set
- Via Hiera using key names like $modulename_$parameter (example: openssh_template) or (default behaviour on Puppet3) openssh::template
- Via Top Scope variables (as the ones that are set in Foreman), like $::openssh_template
On Foreman therefore you have to:
1- Clone Example42 modules in your PuppetMaster's modulepath
2- Have a Foreman-Proxy running on the PuppetMaster
3- Import all the classes in Foreman (Menu More/ Configuration / Puppet Classes / Import from <puppetmaster ). This may take a while.
At this point you have different alternatives on where to place your data:
4a- Once all the classes are imported Foreman can manage directly their parameters and you can use Smart Variables to set them. There parameters are used in parametrized classes declarations (via the ENC).
4b- You can use Foreman to Include classes and set "normal" variables (as the ones you can set per HostGroups/Node/OperatingSystem... in the Parameters tab). These parameters appear as top scope variables.
4c- You can use Foreman to include classes and place on Hiera all your parameters
4d- You can use Foreman to include classes and place your variables in Foreman and/or in your custom site module (where you already have to place your local files and templates).
There are some variations on these patterns, which basically relate to how much information you want to place in Foreman GUI and how much in external files (either hiera or custom modules), but they somehow depend on personal needs and choices.
Your example shows something like -
nrpe_allowed_hosts => [ '127.0.0.1', $::ipaddress, '<nagios server ip>' ]
I'm guessing, since I don't know NRPE and Nagios well enough, that we can't drop the $::ipaddress, and the nagios IP has to be an IP, not a name. I've tried setting a global parameter in Foreman called nagserver and setting it to the nagios server IP, but when the puppet agents run they get 400 Errors. I'm not sure if this is over the nagserver parameter or $::ipaddress. Both appear to show up in the host yaml as literal strings, not substituted with their values.
You wouldn't happen to have a suggestion?
A possible approach can be:
- [Optional] Set on Foreman something like $nagiosserver=<ip of your server>
- Include in Foreman a custom class (like 'site')
- In site/manifests/init.pp, where you have the site class, used by all your modules, you you place something like:
class { 'nrpe':
nrpe_allowed_hosts => [ '127.0.0.1', $::ipaddress, '<nagios server ip>' ],
}
where <nagios server ip> is either $::nagiosserver (the top scope var that you set in Foreman) or directly the ip of your Nagios server.