cloud-mu 3.6.9 → 3.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Berksfile +2 -3
- data/Berksfile.lock +11 -14
- data/bin/mu-aws-setup +16 -4
- data/bin/mu-configure +2 -1
- data/cloud-mu.gemspec +2 -2
- data/cookbooks/mu-firewall/Berksfile +1 -1
- data/cookbooks/mu-firewall/attributes/default.rb +2 -2
- data/cookbooks/mu-firewall/metadata.rb +3 -3
- data/cookbooks/mu-firewall/recipes/default.rb +11 -2
- data/cookbooks/mu-master/Berksfile +1 -1
- data/cookbooks/mu-master/attributes/default.rb +14 -1
- data/cookbooks/mu-master/files/default/389ds-perl/ASDialogs.pm +173 -0
- data/cookbooks/mu-master/files/default/389ds-perl/AdminMigration.pm +569 -0
- data/cookbooks/mu-master/files/default/389ds-perl/AdminServer.pm +952 -0
- data/cookbooks/mu-master/files/default/389ds-perl/AdminUtil.pm +983 -0
- data/cookbooks/mu-master/files/default/389ds-perl/ConfigDSDialogs.pm +449 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSCreate.pm +1551 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSDialogs.pm +233 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSMigration.pm +1175 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSUpdate.pm +534 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSUpdateDialogs.pm +152 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSUtil.pm +1710 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Dialog.pm +249 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DialogManager.pm +212 -0
- data/cookbooks/mu-master/files/default/389ds-perl/FileConn.pm +461 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Inf.pm +268 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Migration.pm +327 -0
- data/cookbooks/mu-master/files/default/389ds-perl/RegDSDialogs.pm +94 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Resource.pm +137 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Setup.pm +240 -0
- data/cookbooks/mu-master/files/default/389ds-perl/SetupDialogs.pm +243 -0
- data/cookbooks/mu-master/files/default/389ds-perl/SetupLog.pm +82 -0
- data/cookbooks/mu-master/files/default/setCertName.ldif +4 -0
- data/cookbooks/mu-master/libraries/mu.rb +2 -2
- data/cookbooks/mu-master/metadata.rb +1 -1
- data/cookbooks/mu-master/recipes/389ds.rb +71 -32
- data/cookbooks/mu-master/recipes/basepackages.rb +5 -0
- data/cookbooks/mu-master/recipes/default.rb +16 -5
- data/cookbooks/mu-master/recipes/init.rb +59 -4
- data/cookbooks/mu-master/recipes/ssl-certs.rb +6 -0
- data/cookbooks/mu-master/recipes/sssd.rb +85 -62
- data/cookbooks/mu-master/recipes/update_nagios_only.rb +7 -1
- data/cookbooks/mu-master/templates/default/389-directory-setup.inf.erb +11 -26
- data/cookbooks/mu-master/templates/default/sssd.conf.erb +18 -8
- data/cookbooks/mu-tools/files/default/Mu_CA.pem +33 -0
- data/cookbooks/mu-tools/metadata.rb +0 -1
- data/cookbooks/mu-tools/recipes/set_local_fw.rb +7 -1
- data/cookbooks/mu-tools/templates/amazon/sshd_config.erb +5 -1
- data/cookbooks/nagios/CHANGELOG.md +679 -0
- data/cookbooks/nagios/LICENSE +201 -0
- data/cookbooks/nagios/README.md +340 -0
- data/cookbooks/nagios/attributes/config.rb +163 -0
- data/cookbooks/nagios/attributes/default.rb +204 -0
- data/cookbooks/nagios/libraries/base.rb +311 -0
- data/cookbooks/nagios/libraries/command.rb +68 -0
- data/cookbooks/nagios/libraries/contact.rb +229 -0
- data/cookbooks/nagios/libraries/contactgroup.rb +111 -0
- data/cookbooks/{firewall/recipes/disable_firewall.rb → nagios/libraries/custom_option.rb} +20 -7
- data/cookbooks/nagios/libraries/data_bag_helper.rb +23 -0
- data/cookbooks/nagios/libraries/default.rb +90 -0
- data/cookbooks/nagios/libraries/helpers.rb +229 -0
- data/cookbooks/nagios/libraries/host.rb +410 -0
- data/cookbooks/nagios/libraries/hostdependency.rb +178 -0
- data/cookbooks/nagios/libraries/hostescalation.rb +170 -0
- data/cookbooks/nagios/libraries/hostgroup.rb +117 -0
- data/cookbooks/nagios/libraries/nagios.rb +277 -0
- data/cookbooks/nagios/libraries/resource.rb +59 -0
- data/cookbooks/nagios/libraries/service.rb +449 -0
- data/cookbooks/nagios/libraries/servicedependency.rb +213 -0
- data/cookbooks/nagios/libraries/serviceescalation.rb +193 -0
- data/cookbooks/nagios/libraries/servicegroup.rb +142 -0
- data/cookbooks/nagios/libraries/timeperiod.rb +159 -0
- data/cookbooks/nagios/libraries/users_helper.rb +54 -0
- data/cookbooks/nagios/metadata.json +44 -0
- data/cookbooks/nagios/metadata.rb +22 -0
- data/cookbooks/nagios/recipes/_load_databag_config.rb +153 -0
- data/cookbooks/nagios/recipes/_load_default_config.rb +241 -0
- data/cookbooks/nagios/recipes/apache.rb +114 -0
- data/cookbooks/nagios/recipes/default.rb +41 -0
- data/cookbooks/nagios/recipes/nginx.rb +114 -0
- data/cookbooks/nagios/recipes/pagerduty.rb +95 -0
- data/cookbooks/nagios/recipes/server.rb +182 -0
- data/cookbooks/nagios/recipes/server_package.rb +85 -0
- data/cookbooks/nagios/recipes/server_source.rb +137 -0
- data/cookbooks/nagios/resources/command.rb +34 -0
- data/cookbooks/nagios/resources/conf.rb +52 -0
- data/cookbooks/nagios/resources/contact.rb +34 -0
- data/cookbooks/nagios/resources/contactgroup.rb +35 -0
- data/cookbooks/nagios/resources/host.rb +35 -0
- data/cookbooks/nagios/resources/hostdependency.rb +35 -0
- data/cookbooks/nagios/resources/hostescalation.rb +36 -0
- data/cookbooks/nagios/resources/hostgroup.rb +35 -0
- data/cookbooks/nagios/resources/resource.rb +34 -0
- data/cookbooks/nagios/resources/service.rb +35 -0
- data/cookbooks/nagios/resources/servicedependency.rb +35 -0
- data/cookbooks/nagios/resources/serviceescalation.rb +35 -0
- data/cookbooks/nagios/resources/servicegroup.rb +35 -0
- data/cookbooks/nagios/resources/timeperiod.rb +35 -0
- data/cookbooks/nagios/templates/apache2.conf.erb +102 -0
- data/cookbooks/nagios/templates/cgi.cfg.erb +266 -0
- data/cookbooks/nagios/templates/commands.cfg.erb +13 -0
- data/cookbooks/nagios/templates/contacts.cfg.erb +37 -0
- data/cookbooks/nagios/templates/hostgroups.cfg.erb +25 -0
- data/cookbooks/nagios/templates/hosts.cfg.erb +15 -0
- data/cookbooks/nagios/templates/htpasswd.users.erb +6 -0
- data/cookbooks/nagios/templates/nagios.cfg.erb +22 -0
- data/cookbooks/nagios/templates/nginx.conf.erb +80 -0
- data/cookbooks/nagios/templates/pagerduty.cgi.erb +185 -0
- data/cookbooks/nagios/templates/resource.cfg.erb +27 -0
- data/cookbooks/nagios/templates/servicedependencies.cfg.erb +15 -0
- data/cookbooks/nagios/templates/servicegroups.cfg.erb +14 -0
- data/cookbooks/nagios/templates/services.cfg.erb +14 -0
- data/cookbooks/nagios/templates/spawn-fcgi.erb +10 -0
- data/cookbooks/nagios/templates/templates.cfg.erb +31 -0
- data/cookbooks/nagios/templates/timeperiods.cfg.erb +13 -0
- data/extras/platform_berksfile_base +3 -3
- data/extras/python_rpm/build.sh +4 -4
- data/extras/python_rpm/muthon.spec +2 -4
- data/extras/vault_tools/export_vaults.sh +11 -1
- data/install/installer +1 -1
- data/modules/mu/kittens.rb +27523 -0
- data/modules/mu/master/ldap.rb +48 -31
- data/modules/mu/master.rb +69 -0
- data/modules/mu/mu.yaml.rb +351 -0
- data/modules/mu/providers/aws/firewall_rule.rb +3 -1
- data/modules/mu/providers/aws.rb +27 -19
- data/modules/mu/providers/google.rb +1 -1
- data/modules/mu.rb +5 -4
- metadata +99 -48
- data/cookbooks/firewall/CHANGELOG.md +0 -488
- data/cookbooks/firewall/LICENSE +0 -202
- data/cookbooks/firewall/README.md +0 -366
- data/cookbooks/firewall/TODO.md +0 -6
- data/cookbooks/firewall/attributes/default.rb +0 -5
- data/cookbooks/firewall/attributes/firewalld.rb +0 -8
- data/cookbooks/firewall/attributes/iptables.rb +0 -17
- data/cookbooks/firewall/attributes/ufw.rb +0 -12
- data/cookbooks/firewall/attributes/windows.rb +0 -8
- data/cookbooks/firewall/libraries/helpers.rb +0 -105
- data/cookbooks/firewall/libraries/helpers_firewalld.rb +0 -116
- data/cookbooks/firewall/libraries/helpers_firewalld_dbus.rb +0 -72
- data/cookbooks/firewall/libraries/helpers_iptables.rb +0 -112
- data/cookbooks/firewall/libraries/helpers_nftables.rb +0 -170
- data/cookbooks/firewall/libraries/helpers_ufw.rb +0 -142
- data/cookbooks/firewall/libraries/helpers_windows.rb +0 -129
- data/cookbooks/firewall/libraries/provider_firewall_firewalld.rb +0 -179
- data/cookbooks/firewall/libraries/provider_firewall_iptables.rb +0 -171
- data/cookbooks/firewall/libraries/provider_firewall_iptables_ubuntu.rb +0 -200
- data/cookbooks/firewall/libraries/provider_firewall_iptables_ubuntu1404.rb +0 -200
- data/cookbooks/firewall/libraries/provider_firewall_rule.rb +0 -34
- data/cookbooks/firewall/libraries/provider_firewall_ufw.rb +0 -138
- data/cookbooks/firewall/libraries/provider_firewall_windows.rb +0 -126
- data/cookbooks/firewall/libraries/resource_firewall.rb +0 -26
- data/cookbooks/firewall/libraries/resource_firewall_rule.rb +0 -52
- data/cookbooks/firewall/metadata.json +0 -40
- data/cookbooks/firewall/metadata.rb +0 -15
- data/cookbooks/firewall/recipes/default.rb +0 -76
- data/cookbooks/firewall/recipes/firewalld.rb +0 -87
- data/cookbooks/firewall/resources/firewalld.rb +0 -28
- data/cookbooks/firewall/resources/firewalld_config.rb +0 -39
- data/cookbooks/firewall/resources/firewalld_helpers.rb +0 -106
- data/cookbooks/firewall/resources/firewalld_icmptype.rb +0 -88
- data/cookbooks/firewall/resources/firewalld_ipset.rb +0 -104
- data/cookbooks/firewall/resources/firewalld_policy.rb +0 -115
- data/cookbooks/firewall/resources/firewalld_service.rb +0 -98
- data/cookbooks/firewall/resources/firewalld_zone.rb +0 -118
- data/cookbooks/firewall/resources/nftables.rb +0 -71
- data/cookbooks/firewall/resources/nftables_rule.rb +0 -113
- data/cookbooks/firewall/templates/default/ufw/default.erb +0 -13
- /data/cookbooks/{firewall → nagios}/chefignore +0 -0
- /data/cookbooks/{firewall → nagios}/renovate.json +0 -0
@@ -0,0 +1,193 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Sander Botman <sbotman@schubergphilis.com>
|
3
|
+
# Cookbook:: nagios
|
4
|
+
# Library:: serviceescalation
|
5
|
+
#
|
6
|
+
# Copyright:: 2014, Sander Botman
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
|
20
|
+
require_relative 'base'
|
21
|
+
|
22
|
+
class Nagios
|
23
|
+
#
|
24
|
+
# This class holds all methods with regard to serviceescalation options,
|
25
|
+
# that are used within nagios configurations.
|
26
|
+
#
|
27
|
+
class Serviceescalation < Nagios::Base
|
28
|
+
attr_reader :service_description,
|
29
|
+
:host_name,
|
30
|
+
:hostgroup_name,
|
31
|
+
:servicegroup_name,
|
32
|
+
:contacts,
|
33
|
+
:contact_groups
|
34
|
+
|
35
|
+
attr_accessor :first_notification,
|
36
|
+
:last_notification,
|
37
|
+
:notification_interval,
|
38
|
+
:escalation_options,
|
39
|
+
:escalation_period
|
40
|
+
|
41
|
+
def initialize(name)
|
42
|
+
@service_description = name
|
43
|
+
@contacts = {}
|
44
|
+
@contact_groups = {}
|
45
|
+
@host_name = {}
|
46
|
+
@hostgroup_name = {}
|
47
|
+
@servicegroup_name = {}
|
48
|
+
super()
|
49
|
+
end
|
50
|
+
|
51
|
+
def definition
|
52
|
+
configured = configured_options
|
53
|
+
unless blank?(servicegroup_name)
|
54
|
+
configured.delete('service_description')
|
55
|
+
configured.delete('host_name')
|
56
|
+
end
|
57
|
+
get_definition(configured, 'serviceescalation')
|
58
|
+
end
|
59
|
+
|
60
|
+
def contacts_list
|
61
|
+
@contacts.values.map(&:to_s).sort.join(',')
|
62
|
+
end
|
63
|
+
|
64
|
+
def contact_groups_list
|
65
|
+
@contact_groups.values.map(&:to_s).sort.join(',')
|
66
|
+
end
|
67
|
+
|
68
|
+
def host_name_list
|
69
|
+
@host_name.values.map(&:to_s).sort.join(',')
|
70
|
+
end
|
71
|
+
|
72
|
+
def hostgroup_name_list
|
73
|
+
@hostgroup_name.values.map(&:to_s).sort.join(',')
|
74
|
+
end
|
75
|
+
|
76
|
+
def servicegroup_name_list
|
77
|
+
@servicegroup_name.values.map(&:to_s).sort.join(',')
|
78
|
+
end
|
79
|
+
|
80
|
+
def import(hash)
|
81
|
+
update_options(hash)
|
82
|
+
update_members(hash, 'contacts', Nagios::Contact)
|
83
|
+
update_members(hash, 'contact_groups', Nagios::Contactgroup)
|
84
|
+
update_members(hash, 'host_name', Nagios::Host)
|
85
|
+
update_members(hash, 'hostgroup_name', Nagios::Hostgroup)
|
86
|
+
update_members(hash, 'servicegroup_name', Nagios::Servicegroup)
|
87
|
+
end
|
88
|
+
|
89
|
+
def push(obj)
|
90
|
+
case obj
|
91
|
+
when Nagios::Host
|
92
|
+
push_object(obj, @host_name)
|
93
|
+
when Nagios::Hostgroup
|
94
|
+
push_object(obj, @hostgroup_name)
|
95
|
+
when Nagios::Servicegroup
|
96
|
+
push_object(obj, @servicegroup_name)
|
97
|
+
when Nagios::Contact
|
98
|
+
push_object(obj, @contacts)
|
99
|
+
when Nagios::Contactgroup
|
100
|
+
push_object(obj, @contact_groups)
|
101
|
+
when Nagios::Timeperiod
|
102
|
+
@escalation_period = obj
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def pop(obj)
|
107
|
+
return if obj == self
|
108
|
+
case obj
|
109
|
+
when Nagios::Host
|
110
|
+
if @host_name.key?(obj.to_s)
|
111
|
+
pop_object(obj, @host_name)
|
112
|
+
pop(self, obj)
|
113
|
+
end
|
114
|
+
when Nagios::Hostgroup
|
115
|
+
if @hostgroup_name.key?(obj.to_s)
|
116
|
+
pop_object(obj, @hostgroup_name)
|
117
|
+
pop(self, obj)
|
118
|
+
end
|
119
|
+
when Nagios::Servicegroup
|
120
|
+
if @servicegroup_name.key?(obj.to_s)
|
121
|
+
pop_object(obj, @servicegroup_name)
|
122
|
+
pop(self, obj)
|
123
|
+
end
|
124
|
+
when Nagios::Contact
|
125
|
+
if @contacts.key?(obj.to_s)
|
126
|
+
pop_object(obj, @contacts)
|
127
|
+
pop(self, obj)
|
128
|
+
end
|
129
|
+
when Nagios::Contactgroup
|
130
|
+
if @contact_groups.key?(obj.to_s)
|
131
|
+
pop_object(obj, @contact_groups)
|
132
|
+
pop(self, obj)
|
133
|
+
end
|
134
|
+
when Nagios::Timeperiod
|
135
|
+
@escalation_period = nil if @escalation_period == obj
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def to_s
|
140
|
+
service_description
|
141
|
+
end
|
142
|
+
|
143
|
+
# check the integer options
|
144
|
+
# default = nil
|
145
|
+
|
146
|
+
def first_notification=(int)
|
147
|
+
@first_notification = check_integer(int)
|
148
|
+
end
|
149
|
+
|
150
|
+
def last_notification=(int)
|
151
|
+
@last_notification = check_integer(int)
|
152
|
+
end
|
153
|
+
|
154
|
+
def notification_interval=(int)
|
155
|
+
@notification_interval = check_integer(int)
|
156
|
+
end
|
157
|
+
|
158
|
+
# check other options
|
159
|
+
|
160
|
+
def escalation_options=(arg)
|
161
|
+
@escalation_options = check_state_options(arg, %w(w u c r), 'escalation_options')
|
162
|
+
end
|
163
|
+
|
164
|
+
private
|
165
|
+
|
166
|
+
def config_options
|
167
|
+
{
|
168
|
+
'name' => 'name',
|
169
|
+
'use' => 'use',
|
170
|
+
'service_description' => 'service_description',
|
171
|
+
'contacts_list' => 'contacts',
|
172
|
+
'contact_groups_list' => 'contact_groups',
|
173
|
+
'escalation_period' => 'escalation_period',
|
174
|
+
'host_name_list' => 'host_name',
|
175
|
+
'hostgroup_name_list' => 'hostgroup_name',
|
176
|
+
'servicegroup_name_list' => 'servicegroup_name',
|
177
|
+
'escalation_options' => 'escalation_options',
|
178
|
+
'first_notification' => 'first_notification',
|
179
|
+
'last_notification' => 'last_notification',
|
180
|
+
'notification_interval' => 'notification_interval',
|
181
|
+
'register' => 'register',
|
182
|
+
}
|
183
|
+
end
|
184
|
+
|
185
|
+
def merge_members(obj)
|
186
|
+
obj.contacts.each { |m| push(m) }
|
187
|
+
obj.host_name.each { |m| push(m) }
|
188
|
+
obj.contact_groups.each { |m| push(m) }
|
189
|
+
obj.hostgroup_name.each { |m| push(m) }
|
190
|
+
obj.servicegroup_name.each { |m| push(m) }
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Sander Botman <sbotman@schubergphilis.com>
|
3
|
+
# Cookbook:: nagios
|
4
|
+
# Library:: servicegroup
|
5
|
+
#
|
6
|
+
# Copyright:: 2014, Sander Botman
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
|
20
|
+
require_relative 'base'
|
21
|
+
|
22
|
+
class Nagios
|
23
|
+
#
|
24
|
+
# This class holds all methods with regard to servicegroup options,
|
25
|
+
# that are used within nagios configurations.
|
26
|
+
#
|
27
|
+
class Servicegroup < Nagios::Base
|
28
|
+
attr_reader :servicegroup_name,
|
29
|
+
:members,
|
30
|
+
:servicegroup_members
|
31
|
+
|
32
|
+
attr_accessor :alias,
|
33
|
+
:notes,
|
34
|
+
:notes_url,
|
35
|
+
:action_url
|
36
|
+
|
37
|
+
def initialize(servicegroup_name)
|
38
|
+
@servicegroup_name = servicegroup_name
|
39
|
+
@members = {}
|
40
|
+
@servicegroup_members = {}
|
41
|
+
super()
|
42
|
+
end
|
43
|
+
|
44
|
+
def definition
|
45
|
+
get_definition(configured_options, 'servicegroup')
|
46
|
+
end
|
47
|
+
|
48
|
+
def import(hash)
|
49
|
+
update_options(hash)
|
50
|
+
update_members(hash, 'members', Nagios::Service, true)
|
51
|
+
update_members(hash, 'servicegroup_members', Nagios::Servicegroup, true)
|
52
|
+
end
|
53
|
+
|
54
|
+
def members_list
|
55
|
+
result = lookup_hostgroup_members
|
56
|
+
result.join(',')
|
57
|
+
end
|
58
|
+
|
59
|
+
def push(obj)
|
60
|
+
case obj
|
61
|
+
when Nagios::Service
|
62
|
+
push_object(obj, @members)
|
63
|
+
when Nagios::Servicegroup
|
64
|
+
push_object(obj, @servicegroup_members)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def pop(obj)
|
69
|
+
return if obj == self
|
70
|
+
case obj
|
71
|
+
when Nagios::Service
|
72
|
+
if @members.key?(obj.to_s)
|
73
|
+
pop_object(obj, @members)
|
74
|
+
pop(self, obj)
|
75
|
+
end
|
76
|
+
when Nagios::Servicegroup
|
77
|
+
if @servicegroup_members.key?(obj.to_s)
|
78
|
+
pop_object(obj, @servicegroup_members)
|
79
|
+
pop(self, obj)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.create(name)
|
85
|
+
Nagios.instance.find(Nagios::Servicegroup.new(name))
|
86
|
+
end
|
87
|
+
|
88
|
+
def servicegroup_members_list
|
89
|
+
@servicegroup_members.values.map(&:to_s).sort.join(',')
|
90
|
+
end
|
91
|
+
|
92
|
+
def to_s
|
93
|
+
servicegroup_name
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def config_options
|
99
|
+
{
|
100
|
+
'servicegroup_name' => 'servicegroup_name',
|
101
|
+
'members_list' => 'members',
|
102
|
+
'servicegroup_members_list' => 'servicegroup_members',
|
103
|
+
'alias' => 'alias',
|
104
|
+
'notes' => 'notes',
|
105
|
+
'notes_url' => 'notes_url',
|
106
|
+
'action_url' => 'action_url',
|
107
|
+
}
|
108
|
+
end
|
109
|
+
|
110
|
+
def convert_hostgroup_hash(hash)
|
111
|
+
result = []
|
112
|
+
hash.sort.to_h.each do |group_name, group_members|
|
113
|
+
group_members.sort.each do |member|
|
114
|
+
result << member
|
115
|
+
result << group_name
|
116
|
+
end
|
117
|
+
end
|
118
|
+
result
|
119
|
+
end
|
120
|
+
|
121
|
+
def lookup_hostgroup_members
|
122
|
+
hostgroup_hash = {}
|
123
|
+
@members.each do |service_name, service_obj|
|
124
|
+
hostgroup_array = []
|
125
|
+
service_obj.hostgroups.each do |hostgroup_name, hostgroup_obj|
|
126
|
+
if service_obj.not_modifiers['hostgroup_name'][hostgroup_name] != '!'
|
127
|
+
hostgroup_array += hostgroup_obj.members.keys
|
128
|
+
else
|
129
|
+
hostgroup_array -= hostgroup_obj.members.keys
|
130
|
+
end
|
131
|
+
end
|
132
|
+
hostgroup_hash[service_name] = hostgroup_array
|
133
|
+
end
|
134
|
+
convert_hostgroup_hash(hostgroup_hash)
|
135
|
+
end
|
136
|
+
|
137
|
+
def merge_members(obj)
|
138
|
+
obj.members.each { |m| push(m) }
|
139
|
+
obj.servicegroup_members.each { |m| push(m) }
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Sander Botman <sbotman@schubergphilis.com>
|
3
|
+
# Cookbook:: nagios
|
4
|
+
# Library:: timeperiod
|
5
|
+
#
|
6
|
+
# Copyright:: 2014, Sander Botman
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
|
20
|
+
require_relative 'base'
|
21
|
+
|
22
|
+
class Nagios
|
23
|
+
#
|
24
|
+
# This class holds all methods with regard to timeperiodentries,
|
25
|
+
# that are used within the timeperiod nagios configurations.
|
26
|
+
#
|
27
|
+
class Timeperiodentry
|
28
|
+
attr_reader :moment,
|
29
|
+
:period
|
30
|
+
|
31
|
+
def initialize(moment, period)
|
32
|
+
@moment = moment
|
33
|
+
@period = check_period(period)
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_s
|
37
|
+
moment
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def check_period(period)
|
43
|
+
return period if period =~ /^(([01]?[0-9]|2[0-3])\:[0-5][0-9]-([01]?[0-9]|2[0-4])\:[0-5][0-9],?)*$/
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
#
|
49
|
+
# This class holds all methods with regard to timeperiod options,
|
50
|
+
# that are used within nagios configurations.
|
51
|
+
#
|
52
|
+
class Timeperiod < Nagios::Base
|
53
|
+
attr_reader :timeperiod_name
|
54
|
+
|
55
|
+
attr_accessor :alias,
|
56
|
+
:periods,
|
57
|
+
:exclude
|
58
|
+
|
59
|
+
def initialize(timeperiod_name)
|
60
|
+
@timeperiod_name = timeperiod_name
|
61
|
+
@periods = {}
|
62
|
+
@exclude = {}
|
63
|
+
super()
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.create(name)
|
67
|
+
Nagios.instance.find(Nagios::Timeperiod.new(name))
|
68
|
+
end
|
69
|
+
|
70
|
+
def definition
|
71
|
+
configured = configured_options
|
72
|
+
periods.each_value { |v| configured[v.moment] = v.period }
|
73
|
+
get_definition(configured, 'timeperiod')
|
74
|
+
end
|
75
|
+
|
76
|
+
# exclude
|
77
|
+
# This directive is used to specify the short names of other timeperiod definitions
|
78
|
+
# whose time ranges should be excluded from this timeperiod.
|
79
|
+
# Multiple timeperiod names should be separated with a comma.
|
80
|
+
|
81
|
+
def exclude
|
82
|
+
@exclude.values.map(&:to_s).sort.join(',')
|
83
|
+
end
|
84
|
+
|
85
|
+
def import(hash)
|
86
|
+
update_options(hash)
|
87
|
+
if hash['times'].respond_to?('each_pair')
|
88
|
+
hash['times'].each { |k, v| push(Nagios::Timeperiodentry.new(k, v)) }
|
89
|
+
end
|
90
|
+
update_members(hash, 'exclude', Nagios::Timeperiod)
|
91
|
+
end
|
92
|
+
|
93
|
+
def push(obj)
|
94
|
+
case obj
|
95
|
+
when Nagios::Timeperiod
|
96
|
+
push_object(obj, @exclude)
|
97
|
+
when Nagios::Timeperiodentry
|
98
|
+
push_object(obj, @periods) unless obj.period.nil?
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def pop(obj)
|
103
|
+
return if obj == self
|
104
|
+
case obj
|
105
|
+
when Nagios::Timeperiod
|
106
|
+
if @exclude.key?(obj.to_s)
|
107
|
+
pop_object(obj, @exclude)
|
108
|
+
pop(self, obj)
|
109
|
+
end
|
110
|
+
when Nagios::Timeperiodentry
|
111
|
+
if @periods.key?(obj.to_s)
|
112
|
+
pop_object(obj, @periods)
|
113
|
+
pop(self, obj)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def to_s
|
119
|
+
timeperiod_name
|
120
|
+
end
|
121
|
+
|
122
|
+
# [weekday]
|
123
|
+
# The weekday directives ("sunday" through "saturday")are comma-delimited
|
124
|
+
# lists of time ranges that are "valid" times for a particular day of the week.
|
125
|
+
# Notice that there are seven different days for which you can define time
|
126
|
+
# ranges (Sunday through Saturday). Each time range is in the form of
|
127
|
+
# HH:MM-HH:MM, where hours are specified on a 24 hour clock.
|
128
|
+
# For example, 00:15-24:00 means 12:15am in the morning for this day until
|
129
|
+
# 12:00am midnight (a 23 hour, 45 minute total time range).
|
130
|
+
# If you wish to exclude an entire day from the timeperiod, simply do not include
|
131
|
+
# it in the timeperiod definition.
|
132
|
+
|
133
|
+
# [exception]
|
134
|
+
# You can specify several different types of exceptions to the standard rotating
|
135
|
+
# weekday schedule. Exceptions can take a number of different forms including single
|
136
|
+
# days of a specific or generic month, single weekdays in a month, or single calendar
|
137
|
+
# dates. You can also specify a range of days/dates and even specify skip intervals
|
138
|
+
# to obtain functionality described by "every 3 days between these dates".
|
139
|
+
# Rather than list all the possible formats for exception strings, I'll let you look
|
140
|
+
# at the example timeperiod definitions above to see what's possible.
|
141
|
+
# Weekdays and different types of exceptions all have different levels of precedence,
|
142
|
+
# so its important to understand how they can affect each other.
|
143
|
+
|
144
|
+
private
|
145
|
+
|
146
|
+
def config_options
|
147
|
+
{
|
148
|
+
'timeperiod_name' => 'timeperiod_name',
|
149
|
+
'alias' => 'alias',
|
150
|
+
'exclude' => 'exclude',
|
151
|
+
}
|
152
|
+
end
|
153
|
+
|
154
|
+
def merge_members(obj)
|
155
|
+
obj.periods.each { |m| push(m) }
|
156
|
+
obj.exclude.each { |m| push(m) }
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'chef/log'
|
2
|
+
require 'chef/search/query'
|
3
|
+
|
4
|
+
# Simplify access to list of all valid Nagios users
|
5
|
+
class NagiosUsers
|
6
|
+
attr_accessor :users
|
7
|
+
|
8
|
+
def initialize(node)
|
9
|
+
@node = node
|
10
|
+
@users = []
|
11
|
+
|
12
|
+
user_databag = node['nagios']['users_databag'].to_sym
|
13
|
+
group = node['nagios']['users_databag_group']
|
14
|
+
|
15
|
+
if node['nagios']['server']['use_encrypted_data_bags']
|
16
|
+
load_encrypted_databag(user_databag)
|
17
|
+
else
|
18
|
+
search_databag(user_databag, group)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def return_user_contacts
|
23
|
+
contacts = []
|
24
|
+
# add base contacts from nagios_users data bag
|
25
|
+
@users.each do |s|
|
26
|
+
contacts << s['id']
|
27
|
+
end
|
28
|
+
contacts
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def fail_search(user_databag)
|
34
|
+
Chef::Log.fatal("\"#{user_databag}\" databag could not be found.")
|
35
|
+
raise "\"#{user_databag}\" databag could not be found."
|
36
|
+
end
|
37
|
+
|
38
|
+
def load_encrypted_databag(user_databag)
|
39
|
+
data_bag(user_databag).each do |u, _|
|
40
|
+
d = data_bag_item(user_databag, u)
|
41
|
+
@users << d unless d['nagios'].nil? || d['nagios']['email'].nil?
|
42
|
+
end
|
43
|
+
rescue Net::HTTPServerException
|
44
|
+
fail_search(user_databag)
|
45
|
+
end
|
46
|
+
|
47
|
+
def search_databag(user_databag, group)
|
48
|
+
Chef::Search::Query.new.search(user_databag, "groups:#{group} NOT action:remove") do |d|
|
49
|
+
@users << d unless d['nagios'].nil? || d['nagios']['email'].nil?
|
50
|
+
end
|
51
|
+
rescue Net::HTTPServerException
|
52
|
+
fail_search(user_databag)
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
{
|
2
|
+
"name": "nagios",
|
3
|
+
"description": "Installs and configures Nagios server",
|
4
|
+
"long_description": "",
|
5
|
+
"maintainer": "Sous Chefs",
|
6
|
+
"maintainer_email": "help@sous-chefs.org",
|
7
|
+
"license": "Apache-2.0",
|
8
|
+
"platforms": {
|
9
|
+
"oracle": ">= 8.0",
|
10
|
+
"redhat": ">= 8.0",
|
11
|
+
"debian": ">= 11.0",
|
12
|
+
"ubuntu": ">= 20.04"
|
13
|
+
},
|
14
|
+
"dependencies": {
|
15
|
+
"apache2": ">= 9.0",
|
16
|
+
"nginx": ">= 11.2",
|
17
|
+
"nrpe": ">= 0.0.0",
|
18
|
+
"php": ">= 10.0",
|
19
|
+
"yum-epel": ">= 0.0.0",
|
20
|
+
"zap": ">= 0.6.0"
|
21
|
+
},
|
22
|
+
"providing": {
|
23
|
+
|
24
|
+
},
|
25
|
+
"recipes": {
|
26
|
+
|
27
|
+
},
|
28
|
+
"version": "12.1.201",
|
29
|
+
"source_url": "https://github.com/sous-chefs/nagios",
|
30
|
+
"issues_url": "https://github.com/sous-chefs/nagios/issues",
|
31
|
+
"privacy": false,
|
32
|
+
"chef_versions": [
|
33
|
+
[
|
34
|
+
">= 15.3"
|
35
|
+
]
|
36
|
+
],
|
37
|
+
"ohai_versions": [
|
38
|
+
|
39
|
+
],
|
40
|
+
"gems": [
|
41
|
+
|
42
|
+
],
|
43
|
+
"eager_load_libraries": true
|
44
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name 'nagios'
|
2
|
+
maintainer 'Sous Chefs'
|
3
|
+
maintainer_email 'help@sous-chefs.org'
|
4
|
+
license 'Apache-2.0'
|
5
|
+
description 'Installs and configures Nagios server. Forked so I can install the correct version of PHP.'
|
6
|
+
version '12.1.201'
|
7
|
+
issues_url 'https://github.com/sous-chefs/nagios/issues'
|
8
|
+
source_url 'https://github.com/sous-chefs/nagios'
|
9
|
+
chef_version '>= 15.3'
|
10
|
+
|
11
|
+
depends 'apache2', '>= 9.0'
|
12
|
+
depends 'nginx', '>= 11.2'
|
13
|
+
depends 'nrpe'
|
14
|
+
depends 'php', '>= 10.0'
|
15
|
+
depends 'yum-epel'
|
16
|
+
depends 'zap', '>= 0.6.0'
|
17
|
+
|
18
|
+
suports 'centos', '>= 8.0'
|
19
|
+
supports 'oracle', '>= 8.0'
|
20
|
+
supports 'redhat', '>= 8.0'
|
21
|
+
supports 'debian', '>= 11.0'
|
22
|
+
supports 'ubuntu', '>= 20.04'
|