Using your own template on nagios module

41 views
Skip to first unread message

Fran Rodríguez

unread,
Jun 25, 2014, 12:35:41 PM6/25/14
to example42-pu...@googlegroups.com
Hi, 

Im trying to modify the template.cfg file on nagios with my own class, monitoring_nagios, im trying to modify attributes for the file nagios_template.cfg with something like this:

class services::monitoring_nagios {

  include nagios::skel
  File <| name == 'nagios_templates.cfg' |> {
    content => template('services/nagios/templates.cfg.erb'),
  }
}

This doesnt work, and i would like to know if i can do it with other way, like nagios class... ?¿

Cheers.

Alessandro Franceschi

unread,
Jun 25, 2014, 1:00:24 PM6/25/14
to example42-pu...@googlegroups.com
Hi,
the module should expose a parameter that allows oveeride of the default template, but it doesn’t, so a solution i could be to have a custom class than inherits the nagios::skel class and hs something ilike:
File[‘nagios_templates.cfg’] {
  content => template('services/nagios/templates.cfg.erb’),
}

Another alternative is to modify directly the template in the nagios module as you wish, but that’s an habit I always discourage.

A third alternative is to submit a PR that allow to provide custom templates for all the templates provided by nagios::skel

Alessandro Franceschi

site { 'Example42 Puppet modules’:
  url       => 'http://www.example42.com',
  before => Service[‘puppet’],
}

--
You received this message because you are subscribed to the Google Groups "Example42 Puppet Modules" group.
To unsubscribe from this group and stop receiving emails from it, send an email to example42-puppet-m...@googlegroups.com.
To post to this group, send email to example42-pu...@googlegroups.com.
Visit this group at http://groups.google.com/group/example42-puppet-modules.
For more options, visit https://groups.google.com/d/optout.

Fran Rodríguez

unread,
Jun 26, 2014, 3:52:47 AM6/26/14
to example42-pu...@googlegroups.com
Hi Al,

Thanks for the answer, the first option is the way to do it... :)

Cheers!


On Wednesday, 25 June 2014 19:00:24 UTC+2, Alessandro Franceschi wrote:
Hi,
the module should expose a parameter that allows oveeride of the default template, but it doesn’t, so a solution i could be to have a custom class than inherits the nagios::skel class and hs something ilike:
File[‘nagios_templates.cfg’] {
  content => template('services/nagios/templates.cfg.erb’),
}

Another alternative is to modify directly the template in the nagios module as you wish, but that’s an habit I always discourage.

A third alternative is to submit a PR that allow to provide custom templates for all the templates provided by nagios::skel

Alessandro Franceschi

site { 'Example42 Puppet modules’:
  url       => 'http://www.example42.com',
  before => Service[‘puppet’],
}

On 25 Jun 2014, at 18:35, Fran Rodríguez <fran.c...@gmail.com> wrote:

Hi, 

Im trying to modify the template.cfg file on nagios with my own class, monitoring_nagios, im trying to modify attributes for the file nagios_template.cfg with something like this:

class services::monitoring_nagios {

  include nagios::skel
  File <| name == 'nagios_templates.cfg' |> {
    content => template('services/nagios/templates.cfg.erb'),
  }
}

This doesnt work, and i would like to know if i can do it with other way, like nagios class... ?¿

Cheers.

--
You received this message because you are subscribed to the Google Groups "Example42 Puppet Modules" group.
To unsubscribe from this group and stop receiving emails from it, send an email to example42-puppet-modules+unsub...@googlegroups.com.

Sean Alderman

unread,
Jul 1, 2014, 12:25:15 PM7/1/14
to example42-pu...@googlegroups.com
Sorry for being late to the game...

I have extended Al's Nagios module, so as to allow puppet to integrate Nagios with PNP4Nagios easily.  I believe it exposes the parameters you're looking for, although its probably not worth of pushing my code back into Al's upstream.


I've exposed several of the templates that the module uses.  Unfortunately this branch might be way behind what's current, merging the upstream changes in is not always easy.  This is how I deploy it on my nagios servers:

  class { 'nagios':
    enablepnp             => true,
    template              => 'sitefiles/nagios/nagios.cfg.erb',
    template_cgi          => 'pnp4nagios/nagios/cgi.cfg',
    settings_template     => 'pnp4nagios/nagios/settings/template.cfg.erb',
    commands_special      => 'pnp4nagios/nagios/commands/special.cfg',
    source_dir_purge      => true,
  }

pnp4nagios is also a puppet module I wrote from Example42 Module Templates, so thats where I pull the specific nagios templates from.

Hope that helps.
Reply all
Reply to author
Forward
0 new messages