summaryrefslogtreecommitdiff
path: root/manifests/base.pp
blob: a32edcfdea5a1c747743e4887d0605181c139ad3 (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
183
184
185
186
class nagios::base {
    # include the variables
    include nagios::defaults::vars

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

    service { 'nagios':
        ensure => running,
        enable => true,
        #hasstatus => true, #fixme!
        require => Package['nagios'],
    }

    # this file should contain all the nagios_puppet-paths:
    file { 'nagios_main_cfg':
            path => "${nagios::defaults::vars::int_nagios_cfgdir}/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'],
            mode => 0644, owner => root, group => root;
    }    

    file { 'nagios_cgi_cfg':
        path => "${nagios::defaults::vars::int_nagios_cfgdir}/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" ],
        mode => '0644', owner => 'root', group => 0,
        notify => Service['apache'],
    }

    file { 'nagios_htpasswd':
        path => "${nagios::defaults::vars::int_nagios_cfgdir}/htpasswd.users",
        source => [ "puppet:///modules/site-nagios/htpasswd.users",
                    "puppet:///modules/nagios/htpasswd.users" ],
        mode => 0640, owner => root, group => apache;
    }

    file { 'nagios_private':
        path => "${nagios::defaults::vars::int_nagios_cfgdir}/private/",
        source => "puppet:///modules/common/empty",
        ensure => directory,
        purge => true,
        recurse => true,
        notify => Service['nagios'],
        mode => '0750', owner => root, group => nagios;
    }

    file { 'nagios_private_resource_cfg':
        path => "${nagios::defaults::vars::int_nagios_cfgdir}/private/resource.cfg",
        source => [ "puppet:///modules/nagios/configs/${operatingsystem}/private/resource.cfg.${architecture}",
                    "puppet:///modules/site-nagios/configs/${operatingsystem}/private/resource.cfg.${architecture}" ],
        notify => Service['nagios'],
        owner => root, group => nagios, mode => '0640';
    }

    file { 'nagios_confd':
        path => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/",
        source => "puppet:///modules/common/empty",
        ensure => directory,
        purge => true,
        recurse => true,
        notify => Service['nagios'],
        mode => '0750', owner => root, group => nagios;
    }
    Package <<| tag == 'nagios::plugin::deploy::package' |>>
    File <<| tag == 'nagios::plugin::deploy::file' |>>
    Nagios_plugin <<||>>
    Nagios_command <<||>>
    Nagios_contact <<||>>
    Nagios_contactgroup <<||>>
    Nagios_host <<||>>
    Nagios_hostextinfo <<||>>
    Nagios_hostgroup <<||>>
    Nagios_hostgroupescalation <<||>>
    Nagios_service <<||>>
    Nagios_servicedependency <<||>>
    Nagios_serviceescalation <<||>>
    Nagios_serviceextinfo <<||>>
    Nagios_timeperiod <<||>>
    File <<| tag == 'nagios_plugin' |>>

    Nagios_command <||> {
        target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_command.cfg",
        require => File['nagios_confd'],
        notify => Service['nagios'],
    }
    Nagios_contact <||> {
        target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contact.cfg",
        require => File['nagios_confd'],
        notify => Service['nagios'],
    }
    Nagios_contactgroup <||> {
        target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contactgroup.cfg",
        require => File['nagios_confd'],
        notify => Service['nagios'],
    }
    Nagios_host <||> {
        target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_host.cfg",
        require => File['nagios_confd'],
        notify => Service['nagios'],
    }
    Nagios_hostextinfo <||> {
        target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostextinfo.cfg",
        require => File['nagios_confd'],
        notify => Service['nagios'],
    }
    Nagios_hostgroup <||> {
        target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostgroup.cfg",
        require => File['nagios_confd'],
        notify => Service['nagios'],
    }
    Nagios_hostgroupescalation <||> {
        target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostgroupescalation.cfg",
        require => File['nagios_confd'],
        notify => Service['nagios'],
    }
    Nagios_service <||> {
        target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_service.cfg",
        require => File['nagios_confd'],
        notify => Service['nagios'],
    }
    Nagios_servicedependency <||> {
        target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicedependency.cfg",
        require => File['nagios_confd'],
        notify => Service['nagios'],
    }
    Nagios_serviceescalation <||> {
        target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceescalation.cfg",
        require => File['nagios_confd'],
        notify => Service['nagios'],
    }
    Nagios_serviceextinfo <||> {
        target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceextinfo.cfg",
        require => File['nagios_confd'],
        notify => Service['nagios'],
    }
    Nagios_timeperiod <||> {
        target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_timeperiod.cfg",
        require => File['nagios_confd'],
        notify => Service['nagios'],
    }

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

    # manage nagios cfg files
    # must be defined after exported resource overrides and cfg file defs
    file { 'nagios_cfgdir':
        path => "${nagios::defaults::vars::int_nagios_cfgdir}/",
        source => "puppet:///modules/common/empty",
        ensure => directory,
        recurse => true,
        purge => true,
        notify => Service['nagios'],
        mode => 0755, owner => root, group => root;
    }

    if $use_munin {
        include nagios::munin
    }

}