summaryrefslogtreecommitdiff
path: root/manifests/base.pp
blob: 4922cdbf648d69a90c831e6a7e1611f34dda0952 (plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# basic stuff for nagios
class nagios::base {
  # include the variables
  include ::nagios::defaults::vars

  package { 'nagios':
    ensure  => present,
  }

  service { 'nagios':
    ensure  => running,
    enable  => $nagios::service_at_boot,
    require => Package['nagios'],
  }

  $cfg_dir = $nagios::defaults::vars::int_cfgdir
  # this file should contain all the nagios_puppet-paths:
  file{
    'nagios_cfgdir':
      ensure  => directory,
      path    => $cfg_dir,
      alias   => nagios_confd,
      recurse => true,
      purge   => true,
      force   => true,
      require => Package['nagios'],
      notify  => Service['nagios'],
      owner   => root,
      group   => root,
      mode    => '0755';
    'nagios_main_cfg':
      path    => "${cfg_dir}/nagios.cfg",
      source  => [ "puppet:///modules/site_nagios/configs/${::fqdn}/nagios.cfg",
                    "puppet:///modules/site_nagios/configs/${::operatingsystem}/nagios.cfg",
                    'puppet:///modules/site_nagios/configs/nagios.cfg',
                    "puppet:///modules/nagios/configs/${::operatingsystem}/nagios.cfg",
                    'puppet:///modules/nagios/configs/nagios.cfg' ],
      notify  => Service['nagios'],
      owner   => root,
      group   => root,
      mode    => '0644';
    'nagios_cgi_cfg':
      path    => "${cfg_dir}/cgi.cfg",
      source  => [ "puppet:///modules/site_nagios/configs/${::fqdn}/cgi.cfg",
                    "puppet:///modules/site_nagios/configs/${::operatingsystem}/cgi.cfg",
                    'puppet:///modules/site_nagios/configs/cgi.cfg',
                    "puppet:///modules/nagios/configs/${::operatingsystem}/cgi.cfg",
                    'puppet:///modules/nagios/configs/cgi.cfg' ],
      notify  => Service['apache'],
      owner   => 'root',
      group   => 0,
      mode    => '0644';
    'nagios_htpasswd':
      path    => "${cfg_dir}/htpasswd.users",
      source  => [ 'puppet:///modules/site_nagios/htpasswd.users',
                    'puppet:///modules/nagios/htpasswd.users' ],
      owner   => root,
      group   => apache,
      mode    => '0640';
    'nagios_resource_cfg':
      path    => "${cfg_dir}/resource.cfg",
      source  => [ "puppet:///modules/site_nagios/configs/${::operatingsystem}/private/resource.cfg.${::architecture}",
                    "puppet:///modules/nagios/configs/${::operatingsystem}/private/resource.cfg.${::architecture}" ],
      notify  => Service['nagios'],
      owner   => root,
      group   => nagios,
      mode    => '0640';
  }

  if $cfg_dir == '/etc/nagios3' {
    file{'/etc/nagios':
      ensure  => link,
      target  => $cfg_dir,
      require => Package['nagios'],
    }
  }

  Nagios_command <<||>>
  Nagios_contactgroup <<||>>
  Nagios_contact <<||>>
  Nagios_hostdependency <<||>>
  Nagios_hostescalation <<||>>
  Nagios_hostextinfo <<||>>
  Nagios_hostgroup <<||>>
  Nagios_host <<||>>
  Nagios_servicedependency <<||>>
  Nagios_serviceescalation <<||>>
  Nagios_servicegroup <<||>>
  Nagios_serviceextinfo <<||>>
  Nagios_service <<||>>
  Nagios_timeperiod <<||>>

  Nagios_command <||> {
    notify  => Service['nagios'],
  }
  Nagios_contact <||> {
    notify  => Service['nagios'],
  }
  Nagios_contactgroup <||> {
    notify  => Service['nagios'],
  }
  Nagios_host <||> {
    notify  => Service['nagios'],
  }
  Nagios_hostdependency <||> {
    notify  => Service['nagios'],
  }
  Nagios_hostescalation <||> {
    notify  => Service['nagios'],
  }
  Nagios_hostextinfo <||> {
    notify  => Service['nagios'],
  }
  Nagios_hostgroup <||> {
    notify  => Service['nagios'],
  }
  Nagios_service <||> {
    notify  => Service['nagios'],
  }
  Nagios_servicegroup <||> {
    notify  => Service['nagios'],
  }
  Nagios_servicedependency <||> {
    notify  => Service['nagios'],
  }
  Nagios_serviceescalation <||> {
    notify  => Service['nagios'],
  }
  Nagios_serviceextinfo <||> {
    notify  => Service['nagios'],
  }
  Nagios_timeperiod <||> {
    notify  => Service['nagios'],
  }

  file{
    [ "${cfg_dir}/nagios_command.cfg",
      "${cfg_dir}/nagios_contact.cfg",
      "${cfg_dir}/nagios_contactgroup.cfg",
      "${cfg_dir}/nagios_host.cfg",
      "${cfg_dir}/nagios_hostdependency.cfg",
      "${cfg_dir}/nagios_hostescalation.cfg",
      "${cfg_dir}/nagios_hostextinfo.cfg",
      "${cfg_dir}/nagios_hostgroup.cfg",
      "${cfg_dir}/nagios_hostgroupescalation.cfg",
      "${cfg_dir}/nagios_service.cfg",
      "${cfg_dir}/nagios_servicedependency.cfg",
      "${cfg_dir}/nagios_serviceescalation.cfg",
      "${cfg_dir}/nagios_serviceextinfo.cfg",
      "${cfg_dir}/nagios_servicegroup.cfg",
      "${cfg_dir}/nagios_timeperiod.cfg" ]:
      ensure  => file,
      replace => false,
      notify  => Service['nagios'],
      owner   => root,
      group   => 0,
      mode    => '0644';
  }

  if $nagios::purge_resources {
    resources {
      [
        'nagios_command',
        'nagios_contactgroup',
        'nagios_contact',
        'nagios_hostdependency',
        'nagios_hostescalation',
        'nagios_hostextinfo',
        'nagios_hostgroup',
        'nagios_host',
        'nagios_servicedependency',
        'nagios_serviceescalation',
        'nagios_servicegroup',
        'nagios_serviceextinfo',
        'nagios_service',
        'nagios_timeperiod',
      ]:
        notify => Service['nagios'],
        purge  => true;
    }
  }
}