Report abuse

modules/nagios/manifests/init.pp

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
class nagios {
  $nagios_cfgdir = '/etc/nagios3'

  include apache

  package {
    nagios3 :
      alias => 'nagios',
      ensure => latest;
    [ 'nagios3-common', 'nagios-plugins-basic' ]:
       ensure => installed,
       before => Package['nagios'];
  }
  service {
    'nagios3':
      alias => 'nagios',
      ensure => running,
      hasstatus => true,
      hasrestart => true,
  }
  file {
    "$nagios_cfgdir/htpasswd.users":
      content => "admin:QqtpoTN5OGzmA",
      mode => 0640,
      owner => root,
      group => www-data,
  }

  File <<| tag == 'nagios' |>>

  define host($ip= $fqdn, $short_alias = $fqdn) {
    @@file {
      "${nagios_cfgdir}/conf.d/${name}_host.cfg":
        ensure => present,
        content => template( "nagios/host.erb" ),
        mode => 644,
        owner => root,
        group => root,
  tag => 'nagios',
    }
  }

  class target {
    debug ( "$fqdn has $nagios_parent as parent" )
    nagios::host { $fqdn: }
  }
}

manifests/nodes.pp

1
2
3
4
5
6
7
8
node 'monitoring' inherits basenode {
  include apache

  include nagios

  $nagios_parent = "generic-host"
  include nagios::target
}

output of puppetd -t -v

1
2
3
4
5
6
7
info: Retrieving plugins
err: /File[/var/lib/puppet/lib]: Failed to generate additional resources during transaction: Cannot access mount[plugins]
err: /File[/var/lib/puppet/lib]: Failed to retrieve current state of resource: Cannot access mount[plugins] Could not describe /plugins: Cannot access mount[plugins]
info: Caching catalog at /var/lib/puppet/state/localconfig.yaml
notice: Starting catalog run
err: //Node[monitoring]/nagios::target/Nagios::Host[]/File[/conf.d/_host.cfg]/ensure: change from absent to present failed: Could not set present on ensure: No such file or directory - /conf.d/_host.cfg.puppettmp at /etc/puppet/modules/nagios/manifests/init.pp:40
notice: Finished catalog run in 3.91 seconds