Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
define nagios::nrpe_command (
 $command, $parameters, $cplugdir="auto", $ensure="present"
# , $nagios_plugin = "<none>"
 , $nagios_plugin
) {

    # find out the default nagios paths for plugis
    $defaultdir = $architecture ? {
                        "x86_64" => "/usr/lib64/nagios/plugins",
                        default  => "/usr/lib/nagios/plugins" }

    # if we overrode cplugdir then use that, else go with the nagios default
    # for this architecture
    case $cplugdir {
        auto:    { $pluginsdir = $defaultdir }
        default: { $pluginsdir = $cplugdir }
    }

    # Package requirements
#    if ( $nagios_plugin != "<none>" ) {
#        # Set a default resource for the file defines coming up...
#        File {
#            require => Package[$nagios_plugin],
#        }
#    }
#    This doesn't work, for reason's not yet known.

    case $ensure {
        "absent":    {  
            file {"/etc/nagios/nrpe.d/${name}.cfg":
                ensure  => absent
            }
            package { $nagios_plugin:
                ensure  => absent,
            }
        }
        default:    {   
            file {"/etc/nagios/nrpe.d/${name}.cfg":
                owner   => root,
                group   => root,
                mode    => 644,
                content => template("nagios/nrpe_remote_d.cfg"),
#                require => File["/etc/nagios/nrpe.d"],
                require => [ File["/etc/nagios/nrpe.d"], Package[$nagios_plugin] ],
            }
            package { $nagios_plugin:
                ensure  => latest,
            }
        }
    }
}