Created
January 16, 2012 06:29
-
-
Save rodjek/1619400 to your computer and use it in GitHub Desktop.
augeas nrpe command editor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define nrpe::command($command, $ensure='present') { | |
Augeas { | |
context => '/files/etc/nrpe.cfg', | |
} | |
case $ensure { | |
absent,present: {} | |
default: { | |
fail("Invalid ensure value passed to Nrpe::Command[$name]") | |
} | |
} | |
if $ensure == 'present' { | |
augeas { | |
"create command ${name}": | |
changes => "set command[last() + 1]/${name} \"${command}\"", | |
onlyif => "match command[./${name}] size == 0"; | |
"set command ${name} to '${command}'": | |
changes => "set command[./${name}]/${name} \"${command}\"", | |
onlyif => "match command[./${name}='${command}'] size == 0", | |
require => Augeas["create command ${name}"]; | |
} | |
} else { | |
augeas { "removing nrpe command ${name}": | |
changes => "rm command[./${name}]", | |
onlyif => "match command[./${name}] size != 0", | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment