NRPE configuration with Augeas

237 views
Skip to first unread message

Jared Curtis

unread,
Jan 14, 2012, 4:27:33 PM1/14/12
to Puppet Users
I'm trying to build a NRPE management module that has the ability to
add or modify existing commands. I think Augeas would be the best
method to handle this but I'm running into a few issues. Here's what I
have so far

define nrpe::command($value) {
include augeas
augeas{ "${fqdn}_NRPE_${name}":
context => "/files/${nrpe::params::conf}",
changes => "set command[last()+1]/${name} ${value}",
onlyif => "get command[*]/${name} != ${value}",
require => Class['augeas'],
}
}

The problem is this will add duplicate commands.

What I want is something like this
nrpe::command { 'check_users': value=> 'check users command';
'check_something': value => 'check something command'; }

Which will produce this
command[check_users]=check users command
command[check_something]=check something command

Any suggestions on how to correct this?

John Morrissey

unread,
Jan 14, 2012, 4:50:44 PM1/14/12
to puppet...@googlegroups.com
On Sat, Jan 14, 2012 at 01:27:33PM -0800, Jared Curtis wrote:
> I'm trying to build a NRPE management module that has the ability to
> add or modify existing commands. I think Augeas would be the best
> method to handle this but I'm running into a few issues. Here's what I
> have so far
[snip]

> The problem is this will add duplicate commands.
>
> What I want is something like this
> nrpe::command { 'check_users': value=> 'check users command';
> 'check_something': value => 'check something command'; }
>
> Which will produce this
> command[check_users]=check users command
> command[check_something]=check something command

I'd say it's easier to use NRPE's include_dir and have nrpe::command drop a
file into that directory for each command, instead of using Augeas to update
a monolithic configuration file. include_dir's been in NRPE for a while,
since version 2.0 AFAICT (released in mid-2003).

john
--
John Morrissey _o /\ ---- __o
j...@horde.net _-< \_ / \ ---- < \,
www.horde.net/ __(_)/_(_)________/ \_______(_) /_(_)__

Tim Sharpe

unread,
Jan 16, 2012, 1:32:26 AM1/16/12
to puppet...@googlegroups.com
You probably want your onlyif to look like

match command[./${name}='${value}'] size == 0

I would probably do something like this (https://gist.github.com/1619400).  The reason for the two augeas resources is one will create the command if it doesn't exist at all, the other will update the named command if it exists but has the wrong command string.
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Jared Curtis

unread,
Jan 17, 2012, 9:09:51 PM1/17/12
to Puppet Users
Thanks for the help guys.

I actually decided to abandon using Augeas as it seemed like overkill
for the project.

I've setup a github page for this project at https://github.com/jaredcurtis/puppet-nrpe.
I started doing this after reading Tim Sharpe's article "Stop writing
puppet modules that suck" (http://bombasticmonkey.com/2011/12/27/stop-
writing-puppet-modules-that-suck/). I was guilty of writing modules
that sucked (they worked but not very flexible). So I re-factored my
existing NRPE module into what I think is a good, clean, flexible, and
reliable module. Would anyone be interested in giving it a once over
and letting me know where I can improve it?
> > To post to this group, send email to puppet...@googlegroups.com (mailto:puppet...@googlegroups.com).
> > To unsubscribe from this group, send email to puppet-users...@googlegroups.com (mailto:puppet-users...@googlegroups.com).
Reply all
Reply to author
Forward
0 new messages