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?
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.
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 commandI''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 jwm@horde.net _-< \_ / \ ---- < \, www.horde.net/ __(_)/_(_)________/ \_______(_) /_(_)__ -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
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.
On Sunday, 15 January 2012 at 8:27 AM, 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
>
> 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?
>
> --
> 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
(mailto:puppet-users@googlegroups.com).
> To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com
(mailto:puppet-users+unsubscribe@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+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.
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? On Jan 15, 10:32 pm, Tim Sharpe <t...@sharpe.id.au> wrote:> 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. > > > > > > > > On Sunday, 15 January 2012 at 8:27 AM, 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 > > > 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? > > > -- > > 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 (mailto:puppet-users@googlegroups.com). > > To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com (mailto:puppet-users+unsubscribe@googlegroups.com). > > For more options, visit this group athttp://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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.