cloud-mu 3.6.10 → 3.6.12

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.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/Berksfile +2 -3
  3. data/Berksfile.lock +11 -14
  4. data/bin/mu-aws-setup +16 -4
  5. data/bin/mu-configure +2 -1
  6. data/cloud-mu.gemspec +3 -3
  7. data/cookbooks/mu-firewall/Berksfile +1 -1
  8. data/cookbooks/mu-firewall/attributes/default.rb +2 -2
  9. data/cookbooks/mu-firewall/metadata.rb +3 -3
  10. data/cookbooks/mu-firewall/recipes/default.rb +11 -2
  11. data/cookbooks/mu-master/Berksfile +1 -1
  12. data/cookbooks/mu-master/attributes/default.rb +14 -1
  13. data/cookbooks/mu-master/files/default/389ds-perl/ASDialogs.pm +173 -0
  14. data/cookbooks/mu-master/files/default/389ds-perl/AdminMigration.pm +569 -0
  15. data/cookbooks/mu-master/files/default/389ds-perl/AdminServer.pm +952 -0
  16. data/cookbooks/mu-master/files/default/389ds-perl/AdminUtil.pm +983 -0
  17. data/cookbooks/mu-master/files/default/389ds-perl/ConfigDSDialogs.pm +449 -0
  18. data/cookbooks/mu-master/files/default/389ds-perl/DSCreate.pm +1551 -0
  19. data/cookbooks/mu-master/files/default/389ds-perl/DSDialogs.pm +233 -0
  20. data/cookbooks/mu-master/files/default/389ds-perl/DSMigration.pm +1175 -0
  21. data/cookbooks/mu-master/files/default/389ds-perl/DSUpdate.pm +534 -0
  22. data/cookbooks/mu-master/files/default/389ds-perl/DSUpdateDialogs.pm +152 -0
  23. data/cookbooks/mu-master/files/default/389ds-perl/DSUtil.pm +1710 -0
  24. data/cookbooks/mu-master/files/default/389ds-perl/Dialog.pm +249 -0
  25. data/cookbooks/mu-master/files/default/389ds-perl/DialogManager.pm +212 -0
  26. data/cookbooks/mu-master/files/default/389ds-perl/FileConn.pm +461 -0
  27. data/cookbooks/mu-master/files/default/389ds-perl/Inf.pm +268 -0
  28. data/cookbooks/mu-master/files/default/389ds-perl/Migration.pm +327 -0
  29. data/cookbooks/mu-master/files/default/389ds-perl/RegDSDialogs.pm +94 -0
  30. data/cookbooks/mu-master/files/default/389ds-perl/Resource.pm +137 -0
  31. data/cookbooks/mu-master/files/default/389ds-perl/Setup.pm +240 -0
  32. data/cookbooks/mu-master/files/default/389ds-perl/SetupDialogs.pm +243 -0
  33. data/cookbooks/mu-master/files/default/389ds-perl/SetupLog.pm +82 -0
  34. data/cookbooks/mu-master/files/default/setCertName.ldif +4 -0
  35. data/cookbooks/mu-master/libraries/mu.rb +2 -2
  36. data/cookbooks/mu-master/metadata.rb +1 -1
  37. data/cookbooks/mu-master/recipes/389ds.rb +71 -32
  38. data/cookbooks/mu-master/recipes/basepackages.rb +5 -0
  39. data/cookbooks/mu-master/recipes/default.rb +16 -5
  40. data/cookbooks/mu-master/recipes/init.rb +36 -3
  41. data/cookbooks/mu-master/recipes/ssl-certs.rb +6 -0
  42. data/cookbooks/mu-master/recipes/sssd.rb +85 -62
  43. data/cookbooks/mu-master/recipes/update_nagios_only.rb +7 -1
  44. data/cookbooks/mu-master/templates/default/389-directory-setup.inf.erb +11 -26
  45. data/cookbooks/mu-master/templates/default/sssd.conf.erb +18 -8
  46. data/cookbooks/mu-tools/files/default/Mu_CA.pem +33 -0
  47. data/cookbooks/mu-tools/metadata.rb +0 -1
  48. data/cookbooks/mu-tools/recipes/set_local_fw.rb +7 -1
  49. data/cookbooks/mu-tools/templates/amazon/sshd_config.erb +5 -1
  50. data/cookbooks/nagios/CHANGELOG.md +679 -0
  51. data/cookbooks/nagios/LICENSE +201 -0
  52. data/cookbooks/nagios/README.md +340 -0
  53. data/cookbooks/nagios/attributes/config.rb +163 -0
  54. data/cookbooks/nagios/attributes/default.rb +204 -0
  55. data/cookbooks/nagios/libraries/base.rb +311 -0
  56. data/cookbooks/nagios/libraries/command.rb +68 -0
  57. data/cookbooks/nagios/libraries/contact.rb +229 -0
  58. data/cookbooks/nagios/libraries/contactgroup.rb +111 -0
  59. data/cookbooks/{firewall/recipes/disable_firewall.rb → nagios/libraries/custom_option.rb} +20 -7
  60. data/cookbooks/nagios/libraries/data_bag_helper.rb +23 -0
  61. data/cookbooks/nagios/libraries/default.rb +90 -0
  62. data/cookbooks/nagios/libraries/helpers.rb +229 -0
  63. data/cookbooks/nagios/libraries/host.rb +410 -0
  64. data/cookbooks/nagios/libraries/hostdependency.rb +178 -0
  65. data/cookbooks/nagios/libraries/hostescalation.rb +170 -0
  66. data/cookbooks/nagios/libraries/hostgroup.rb +117 -0
  67. data/cookbooks/nagios/libraries/nagios.rb +277 -0
  68. data/cookbooks/nagios/libraries/resource.rb +59 -0
  69. data/cookbooks/nagios/libraries/service.rb +449 -0
  70. data/cookbooks/nagios/libraries/servicedependency.rb +213 -0
  71. data/cookbooks/nagios/libraries/serviceescalation.rb +193 -0
  72. data/cookbooks/nagios/libraries/servicegroup.rb +142 -0
  73. data/cookbooks/nagios/libraries/timeperiod.rb +159 -0
  74. data/cookbooks/nagios/libraries/users_helper.rb +54 -0
  75. data/cookbooks/nagios/metadata.json +44 -0
  76. data/cookbooks/nagios/metadata.rb +22 -0
  77. data/cookbooks/nagios/recipes/_load_databag_config.rb +153 -0
  78. data/cookbooks/nagios/recipes/_load_default_config.rb +241 -0
  79. data/cookbooks/nagios/recipes/apache.rb +114 -0
  80. data/cookbooks/nagios/recipes/default.rb +41 -0
  81. data/cookbooks/nagios/recipes/nginx.rb +114 -0
  82. data/cookbooks/nagios/recipes/pagerduty.rb +95 -0
  83. data/cookbooks/nagios/recipes/server.rb +182 -0
  84. data/cookbooks/nagios/recipes/server_package.rb +85 -0
  85. data/cookbooks/nagios/recipes/server_source.rb +137 -0
  86. data/cookbooks/nagios/resources/command.rb +34 -0
  87. data/cookbooks/nagios/resources/conf.rb +52 -0
  88. data/cookbooks/nagios/resources/contact.rb +34 -0
  89. data/cookbooks/nagios/resources/contactgroup.rb +35 -0
  90. data/cookbooks/nagios/resources/host.rb +35 -0
  91. data/cookbooks/nagios/resources/hostdependency.rb +35 -0
  92. data/cookbooks/nagios/resources/hostescalation.rb +36 -0
  93. data/cookbooks/nagios/resources/hostgroup.rb +35 -0
  94. data/cookbooks/nagios/resources/resource.rb +34 -0
  95. data/cookbooks/nagios/resources/service.rb +35 -0
  96. data/cookbooks/nagios/resources/servicedependency.rb +35 -0
  97. data/cookbooks/nagios/resources/serviceescalation.rb +35 -0
  98. data/cookbooks/nagios/resources/servicegroup.rb +35 -0
  99. data/cookbooks/nagios/resources/timeperiod.rb +35 -0
  100. data/cookbooks/nagios/templates/apache2.conf.erb +102 -0
  101. data/cookbooks/nagios/templates/cgi.cfg.erb +266 -0
  102. data/cookbooks/nagios/templates/commands.cfg.erb +13 -0
  103. data/cookbooks/nagios/templates/contacts.cfg.erb +37 -0
  104. data/cookbooks/nagios/templates/hostgroups.cfg.erb +25 -0
  105. data/cookbooks/nagios/templates/hosts.cfg.erb +15 -0
  106. data/cookbooks/nagios/templates/htpasswd.users.erb +6 -0
  107. data/cookbooks/nagios/templates/nagios.cfg.erb +22 -0
  108. data/cookbooks/nagios/templates/nginx.conf.erb +80 -0
  109. data/cookbooks/nagios/templates/pagerduty.cgi.erb +185 -0
  110. data/cookbooks/nagios/templates/resource.cfg.erb +27 -0
  111. data/cookbooks/nagios/templates/servicedependencies.cfg.erb +15 -0
  112. data/cookbooks/nagios/templates/servicegroups.cfg.erb +14 -0
  113. data/cookbooks/nagios/templates/services.cfg.erb +14 -0
  114. data/cookbooks/nagios/templates/spawn-fcgi.erb +10 -0
  115. data/cookbooks/nagios/templates/templates.cfg.erb +31 -0
  116. data/cookbooks/nagios/templates/timeperiods.cfg.erb +13 -0
  117. data/extras/platform_berksfile_base +3 -3
  118. data/extras/python_rpm/build.sh +4 -4
  119. data/extras/python_rpm/muthon.spec +2 -4
  120. data/extras/vault_tools/export_vaults.sh +11 -1
  121. data/install/installer +1 -1
  122. data/modules/mu/kittens.rb +27523 -0
  123. data/modules/mu/master/ldap.rb +48 -31
  124. data/modules/mu/master.rb +69 -0
  125. data/modules/mu/mu.yaml.rb +351 -0
  126. data/modules/mu/providers/aws/firewall_rule.rb +3 -1
  127. data/modules/mu/providers/aws.rb +11 -5
  128. data/modules/mu.rb +5 -4
  129. metadata +99 -68
  130. data/cookbooks/firewall/CHANGELOG.md +0 -488
  131. data/cookbooks/firewall/LICENSE +0 -202
  132. data/cookbooks/firewall/README.md +0 -366
  133. data/cookbooks/firewall/TODO.md +0 -6
  134. data/cookbooks/firewall/attributes/default.rb +0 -5
  135. data/cookbooks/firewall/attributes/firewalld.rb +0 -8
  136. data/cookbooks/firewall/attributes/iptables.rb +0 -17
  137. data/cookbooks/firewall/attributes/ufw.rb +0 -12
  138. data/cookbooks/firewall/attributes/windows.rb +0 -8
  139. data/cookbooks/firewall/libraries/helpers.rb +0 -105
  140. data/cookbooks/firewall/libraries/helpers_firewalld.rb +0 -116
  141. data/cookbooks/firewall/libraries/helpers_firewalld_dbus.rb +0 -72
  142. data/cookbooks/firewall/libraries/helpers_iptables.rb +0 -112
  143. data/cookbooks/firewall/libraries/helpers_nftables.rb +0 -170
  144. data/cookbooks/firewall/libraries/helpers_ufw.rb +0 -142
  145. data/cookbooks/firewall/libraries/helpers_windows.rb +0 -129
  146. data/cookbooks/firewall/libraries/provider_firewall_firewalld.rb +0 -179
  147. data/cookbooks/firewall/libraries/provider_firewall_iptables.rb +0 -171
  148. data/cookbooks/firewall/libraries/provider_firewall_iptables_ubuntu.rb +0 -200
  149. data/cookbooks/firewall/libraries/provider_firewall_iptables_ubuntu1404.rb +0 -200
  150. data/cookbooks/firewall/libraries/provider_firewall_rule.rb +0 -34
  151. data/cookbooks/firewall/libraries/provider_firewall_ufw.rb +0 -138
  152. data/cookbooks/firewall/libraries/provider_firewall_windows.rb +0 -126
  153. data/cookbooks/firewall/libraries/resource_firewall.rb +0 -26
  154. data/cookbooks/firewall/libraries/resource_firewall_rule.rb +0 -52
  155. data/cookbooks/firewall/metadata.json +0 -40
  156. data/cookbooks/firewall/metadata.rb +0 -15
  157. data/cookbooks/firewall/recipes/default.rb +0 -76
  158. data/cookbooks/firewall/recipes/firewalld.rb +0 -87
  159. data/cookbooks/firewall/resources/firewalld.rb +0 -28
  160. data/cookbooks/firewall/resources/firewalld_config.rb +0 -39
  161. data/cookbooks/firewall/resources/firewalld_helpers.rb +0 -106
  162. data/cookbooks/firewall/resources/firewalld_icmptype.rb +0 -88
  163. data/cookbooks/firewall/resources/firewalld_ipset.rb +0 -104
  164. data/cookbooks/firewall/resources/firewalld_policy.rb +0 -115
  165. data/cookbooks/firewall/resources/firewalld_service.rb +0 -98
  166. data/cookbooks/firewall/resources/firewalld_zone.rb +0 -118
  167. data/cookbooks/firewall/resources/nftables.rb +0 -71
  168. data/cookbooks/firewall/resources/nftables_rule.rb +0 -113
  169. data/cookbooks/firewall/templates/default/ufw/default.erb +0 -13
  170. /data/cookbooks/{firewall → nagios}/chefignore +0 -0
  171. /data/cookbooks/{firewall → nagios}/renovate.json +0 -0
@@ -0,0 +1,153 @@
1
+ #
2
+ # Author:: Sander Botman <sbotman@schubergphilis.com>
3
+ # Cookbook:: nagios
4
+ # Recipe:: _load_databag_config
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
+ # Loading all databag information
21
+ nagios_bags = NagiosDataBags.new
22
+
23
+ hostgroups = nagios_bags.get(node['nagios']['hostgroups_databag'])
24
+ hostgroups.each do |group|
25
+ next if group['search_query'].nil?
26
+ if node['nagios']['multi_environment_monitoring']
27
+ query_environments = node['nagios']['monitored_environments'].map do |environment|
28
+ "chef_environment:#{environment}"
29
+ end.join(' OR ')
30
+ result = search(:node, "(#{group['search_query']}) AND (#{query_environments})")
31
+ else
32
+ result = search(:node, "#{group['search_query']} AND chef_environment:#{node.chef_environment}")
33
+ end
34
+
35
+ result.each do |n|
36
+ n.automatic_attrs['roles'] = [group['hostgroup_name']]
37
+ Nagios.instance.push(n)
38
+ end
39
+ end
40
+
41
+ services = nagios_bags.get(node['nagios']['services_databag'])
42
+ services.each do |item|
43
+ next unless item['activate_check_in_environment'].nil? || item['activate_check_in_environment'].include?(node.chef_environment)
44
+ name = item['service_description'] || item['id']
45
+ check_command = name.downcase.start_with?('check_') ? name.downcase : 'check_' + name.downcase
46
+ command_name = item['check_command'].nil? ? check_command : item['check_command']
47
+ service_name = name.downcase.start_with?('check_') ? name.gsub('check_', '') : name.downcase
48
+ item['check_command'] = command_name
49
+
50
+ nagios_command command_name do
51
+ options item
52
+ end
53
+
54
+ nagios_service service_name do
55
+ options item
56
+ end
57
+ end
58
+
59
+ contactgroups = nagios_bags.get(node['nagios']['contactgroups_databag'])
60
+ contactgroups.each do |item|
61
+ name = item['contactgroup_name'] || item['id']
62
+ nagios_contactgroup name do
63
+ options item
64
+ end
65
+ end
66
+
67
+ eventhandlers = nagios_bags.get(node['nagios']['eventhandlers_databag'])
68
+ eventhandlers.each do |item|
69
+ name = item['command_name'] || item['id']
70
+ nagios_command name do
71
+ options item
72
+ end
73
+ end
74
+
75
+ contacts = nagios_bags.get(node['nagios']['contacts_databag'])
76
+ contacts.each do |item|
77
+ name = item['contact_name'] || item['id']
78
+ nagios_contact name do
79
+ options item
80
+ end
81
+ end
82
+
83
+ hostescalations = nagios_bags.get(node['nagios']['hostescalations_databag'])
84
+ hostescalations.each do |item|
85
+ name = item['host_description'] || item['id']
86
+ nagios_hostescalation name do
87
+ options item
88
+ end
89
+ end
90
+
91
+ hosttemplates = nagios_bags.get(node['nagios']['hosttemplates_databag'])
92
+ hosttemplates.each do |item|
93
+ name = item['host_name'] || item['id']
94
+ item['name'] = name if item['name'].nil?
95
+ nagios_host name do
96
+ options item
97
+ end
98
+ end
99
+
100
+ servicedependencies = nagios_bags.get(node['nagios']['servicedependencies_databag'])
101
+ servicedependencies.each do |item|
102
+ name = item['service_description'] || item['id']
103
+ nagios_servicedependency name do
104
+ options item
105
+ end
106
+ end
107
+
108
+ serviceescalations = nagios_bags.get(node['nagios']['serviceescalations_databag'])
109
+ serviceescalations.each do |item|
110
+ name = item['service_description'] || item['id']
111
+ nagios_serviceescalation name do
112
+ options item
113
+ end
114
+ end
115
+
116
+ servicegroups = nagios_bags.get(node['nagios']['servicegroups_databag'])
117
+ servicegroups.each do |item|
118
+ name = item['servicegroup_name'] || item['id']
119
+ nagios_servicegroup name do
120
+ options item
121
+ end
122
+ end
123
+
124
+ templates = nagios_bags.get(node['nagios']['templates_databag'])
125
+ templates.each do |item|
126
+ name = item['name'] || item['id']
127
+ item['name'] = name
128
+ nagios_service name do
129
+ options item
130
+ end
131
+ end
132
+
133
+ timeperiods = nagios_bags.get(node['nagios']['timeperiods_databag'])
134
+ timeperiods.each do |item|
135
+ name = item['timeperiod_name'] || item['id']
136
+ nagios_timeperiod name do
137
+ options item
138
+ end
139
+ end
140
+
141
+ unmanaged_hosts = nagios_bags.get(node['nagios']['unmanagedhosts_databag'])
142
+ unmanaged_hosts.each do |item|
143
+ if node['nagios']['multi_environment_monitoring'].nil?
144
+ next if item['environment'].nil? || item['environment'] != node.chef_environment
145
+ else
146
+ envs = node['nagios']['monitored_environments']
147
+ next if item['environment'].nil? || !envs.include?(item['environment'])
148
+ end
149
+ name = item['host_name'] || item['id']
150
+ nagios_host name do
151
+ options item
152
+ end
153
+ end
@@ -0,0 +1,241 @@
1
+ #
2
+ # Author:: Sander Botman <sbotman@schubergphilis.com>
3
+ # Cookbook:: nagios
4
+ # Recipe:: _load_default_config
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
+ # Find nodes to monitor.
21
+ # Search in all environments if multi_environment_monitoring is enabled.
22
+ Chef::Log.info('Beginning search for nodes. This may take some time depending on your node count')
23
+
24
+ multi_env = node['nagios']['monitored_environments']
25
+ multi_env_search = multi_env.empty? ? '' : ' AND (chef_environment:' + multi_env.join(' OR chef_environment:') + ')'
26
+
27
+ nodes = if node['nagios']['multi_environment_monitoring']
28
+ search(:node, "name:*#{multi_env_search}")
29
+ else
30
+ search(:node, "name:* AND chef_environment:#{node.chef_environment}")
31
+ end
32
+
33
+ if nodes.empty?
34
+ Chef::Log.info('No nodes returned from search, using this node so hosts.cfg has data')
35
+ nodes << node
36
+ end
37
+
38
+ # Pushing current node to prevent empty hosts.cfg
39
+ Nagios.instance.push(node)
40
+
41
+ # Pushing all nodes into the Nagios.instance model
42
+ exclude_tag = nagios_array(node['nagios']['exclude_tag_host'])
43
+ nodes.each do |n|
44
+ if n.respond_to?('tags')
45
+ Nagios.instance.push(n) unless nagios_array(n.tags).any? { |tag| exclude_tag.include?(tag) }
46
+ else
47
+ Nagios.instance.push(n)
48
+ end
49
+ end
50
+
51
+ # 24x7 timeperiod
52
+ nagios_timeperiod '24x7' do
53
+ options 'alias' => '24 Hours A Day, 7 Days A Week',
54
+ 'times' => { 'sunday' => '00:00-24:00',
55
+ 'monday' => '00:00-24:00',
56
+ 'tuesday' => '00:00-24:00',
57
+ 'wednesday' => '00:00-24:00',
58
+ 'thursday' => '00:00-24:00',
59
+ 'friday' => '00:00-24:00',
60
+ 'saturday' => '00:00-24:00' }
61
+ end
62
+
63
+ # Host checks
64
+ nagios_command 'check_host_alive' do
65
+ options 'command_line' => '$USER1$/check_ping -H $HOSTADDRESS$ -w 2000,80% -c 3000,100% -p 1'
66
+ end
67
+
68
+ # Service checks
69
+ nagios_command 'check_nagios' do
70
+ options 'command_line' => '$USER1$/check_nrpe -H $HOSTADDRESS$ -c check_nagios -t 20'
71
+ end
72
+
73
+ # nrpe remote host checks
74
+ nagios_command 'check_nrpe_alive' do
75
+ options 'command_line' => '$USER1$/check_nrpe -H $HOSTADDRESS$ -t 20'
76
+ end
77
+
78
+ nagios_command 'check_nrpe' do
79
+ options 'command_line' => '$USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -t 20'
80
+ end
81
+
82
+ # host_notify_by_email command
83
+ nagios_command 'host_notify_by_email' do
84
+ options 'command_line' => '/usr/bin/printf "%b" "$LONGDATETIME$\n\n$HOSTALIAS$ $NOTIFICATIONTYPE$ $HOSTSTATE$\n\n$HOSTOUTPUT$\n\nLogin: ssh://$HOSTNAME$" | ' + node['nagios']['server']['mail_command'] + ' -s "$NOTIFICATIONTYPE$ - $HOSTALIAS$ $HOSTSTATE$!" $CONTACTEMAIL$'
85
+ end
86
+
87
+ # service_notify_by_email command
88
+ nagios_command 'service_notify_by_email' do
89
+ options 'command_line' => '/usr/bin/printf "%b" "$LONGDATETIME$ - $SERVICEDESC$ $SERVICESTATE$\n\n$HOSTALIAS$ $NOTIFICATIONTYPE$\n\n$SERVICEOUTPUT$\n\nLogin: ssh://$HOSTNAME$" | ' + node['nagios']['server']['mail_command'] + ' -s "** $NOTIFICATIONTYPE$ - $HOSTALIAS$ - $SERVICEDESC$ - $SERVICESTATE$" $CONTACTEMAIL$'
90
+ end
91
+
92
+ # host_notify_by_sms_email command
93
+ nagios_command 'host_notify_by_sms_email' do
94
+ options 'command_line' => '/usr/bin/printf "%b" "$HOSTALIAS$ $NOTIFICATIONTYPE$ $HOSTSTATE$\n\n$HOSTOUTPUT$" | ' + node['nagios']['server']['mail_command'] + ' -s "$HOSTALIAS$ $HOSTSTATE$!" $CONTACTPAGER$'
95
+ end
96
+
97
+ # service_notify_by_sms_email command
98
+ nagios_command 'service_notify_by_sms_email' do
99
+ options 'command_line' => '/usr/bin/printf "%b" "$SERVICEDESC$ $NOTIFICATIONTYPE$ $SERVICESTATE$\n\n$SERVICEOUTPUT$" | ' + node['nagios']['server']['mail_command'] + ' -s "$HOSTALIAS$ $SERVICEDESC$ $SERVICESTATE$!" $CONTACTPAGER$'
100
+ end
101
+
102
+ # root contact
103
+ nagios_contact 'root' do
104
+ options 'alias' => 'Root',
105
+ 'service_notification_period' => '24x7',
106
+ 'host_notification_period' => '24x7',
107
+ 'service_notification_options' => 'w,u,c,r',
108
+ 'host_notification_options' => 'd,r',
109
+ 'service_notification_commands' => 'service_notify_by_email',
110
+ 'host_notification_commands' => 'host_notify_by_email',
111
+ 'email' => 'root@localhost'
112
+ end
113
+
114
+ # admin contact
115
+ nagios_contact 'admin' do
116
+ options 'alias' => 'Admin',
117
+ 'service_notification_period' => '24x7',
118
+ 'host_notification_period' => '24x7',
119
+ 'service_notification_options' => 'w,u,c,r',
120
+ 'host_notification_options' => 'd,r',
121
+ 'service_notification_commands' => 'service_notify_by_email',
122
+ 'host_notification_commands' => 'host_notify_by_email'
123
+ end
124
+
125
+ nagios_contact 'default-contact' do
126
+ options 'name' => 'default-contact',
127
+ 'service_notification_period' => '24x7',
128
+ 'host_notification_period' => '24x7',
129
+ 'service_notification_options' => 'w,u,c,r,f',
130
+ 'host_notification_options' => 'd,u,r,f,s',
131
+ 'service_notification_commands' => 'service_notify_by_email',
132
+ 'host_notification_commands' => 'host_notify_by_email'
133
+ end
134
+
135
+ nagios_host 'default-host' do
136
+ options 'name' => 'default-host',
137
+ 'notifications_enabled' => 1,
138
+ 'event_handler_enabled' => 1,
139
+ 'flap_detection_enabled' => nagios_boolean(nagios_attr(:default_host)[:flap_detection]),
140
+ 'process_perf_data' => nagios_boolean(nagios_attr(:default_host)[:process_perf_data]),
141
+ 'retain_status_information' => 1,
142
+ 'retain_nonstatus_information' => 1,
143
+ 'notification_period' => '24x7',
144
+ 'register' => 0,
145
+ 'action_url' => nagios_attr(:default_host)[:action_url]
146
+ end
147
+
148
+ nagios_host 'server' do
149
+ options 'name' => 'server',
150
+ 'use' => 'default-host',
151
+ 'check_period' => nagios_attr(:default_host)[:check_period],
152
+ 'check_interval' => nagios_interval(nagios_attr(:default_host)[:check_interval]),
153
+ 'retry_interval' => nagios_interval(nagios_attr(:default_host)[:retry_interval]),
154
+ 'max_check_attempts' => nagios_attr(:default_host)[:max_check_attempts],
155
+ 'check_command' => nagios_attr(:default_host)[:check_command],
156
+ 'notification_interval' => nagios_interval(nagios_attr(:default_host)[:notification_interval]),
157
+ 'notification_options' => nagios_attr(:default_host)[:notification_options],
158
+ 'contact_groups' => nagios_attr(:default_contact_groups),
159
+ 'register' => 0
160
+ end
161
+
162
+ # Defaut host template
163
+ Nagios.instance.default_host = node['nagios']['host_template']
164
+
165
+ # Users
166
+ # use the users_helper.rb library to build arrays of users and contacts
167
+ nagios_users = NagiosUsers.new(node)
168
+ nagios_users.users.each do |item|
169
+ o = Nagios::Contact.create(item['id'])
170
+ o.import(item.to_hash)
171
+ o.import(item['nagios'].to_hash) unless item['nagios'].nil?
172
+ o.use = 'default-contact'
173
+ end
174
+
175
+ nagios_contactgroup 'admins' do
176
+ options 'alias' => 'Nagios Administrators',
177
+ 'members' => nagios_users.return_user_contacts
178
+ end
179
+
180
+ nagios_contactgroup 'admins-sms' do
181
+ options 'alias' => 'Sysadmin SMS',
182
+ 'members' => nagios_users.return_user_contacts
183
+ end
184
+
185
+ # Services
186
+ nagios_service 'default-service' do
187
+ options 'name' => 'default-service',
188
+ 'active_checks_enabled' => 1,
189
+ 'passive_checks_enabled' => 1,
190
+ 'parallelize_check' => 1,
191
+ 'obsess_over_service' => 1,
192
+ 'check_freshness' => 0,
193
+ 'notifications_enabled' => 1,
194
+ 'event_handler_enabled' => 1,
195
+ 'flap_detection_enabled' => nagios_boolean(nagios_attr(:default_service)[:flap_detection]),
196
+ 'process_perf_data' => nagios_boolean(nagios_attr(:default_service)[:process_perf_data]),
197
+ 'retain_status_information' => 1,
198
+ 'retain_nonstatus_information' => 1,
199
+ 'is_volatile' => 0,
200
+ 'check_period' => '24x7',
201
+ 'max_check_attempts' => nagios_attr(:default_service)[:max_check_attempts],
202
+ 'check_interval' => nagios_interval(nagios_attr(:default_service)[:check_interval]),
203
+ 'retry_interval' => nagios_interval(nagios_attr(:default_service)[:retry_interval]),
204
+ 'contact_groups' => nagios_attr(:default_contact_groups),
205
+ 'notification_options' => 'w,u,c,r',
206
+ 'notification_interval' => nagios_interval(nagios_attr(:default_service)[:notification_interval]),
207
+ 'notification_period' => '24x7',
208
+ 'register' => 0,
209
+ 'action_url' => nagios_attr(:default_service)[:action_url]
210
+ end
211
+
212
+ # Default service template
213
+ Nagios.instance.default_service = 'default-service'
214
+
215
+ # Define the log monitoring template (monitoring logs is very different)
216
+ nagios_service 'default-logfile' do
217
+ options 'name' => 'default-logfile',
218
+ 'use' => 'default-service',
219
+ 'check_period' => '24x7',
220
+ 'max_check_attempts' => 1,
221
+ 'check_interval' => nagios_interval(nagios_attr(:default_service)[:check_interval]),
222
+ 'retry_interval' => nagios_interval(nagios_attr(:default_service)[:retry_interval]),
223
+ 'contact_groups' => nagios_attr(:default_contact_groups),
224
+ 'notification_options' => 'w,u,c,r',
225
+ 'notification_period' => '24x7',
226
+ 'register' => 0,
227
+ 'is_volatile' => 1
228
+ end
229
+
230
+ nagios_service 'service-template' do
231
+ options 'name' => 'service-template',
232
+ 'max_check_attempts' => nagios_attr(:default_service)[:max_check_attempts],
233
+ 'check_interval' => nagios_interval(nagios_attr(:default_service)[:check_interval]),
234
+ 'retry_interval' => nagios_interval(nagios_attr(:default_service)[:retry_interval]),
235
+ 'notification_interval' => nagios_interval(nagios_attr(:default_service)[:notification_interval]),
236
+ 'register' => 0
237
+ end
238
+
239
+ nagios_resource 'USER1' do
240
+ options 'value' => node['nagios']['plugin_dir']
241
+ end
@@ -0,0 +1,114 @@
1
+ #
2
+ # Author:: Tim Smith <tsmith@chef.io>
3
+ # Cookbook:: nagios
4
+ # Recipe:: apache
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ node.default['nagios']['server']['web_server'] = 'apache'
20
+
21
+ php_install 'php' do
22
+ packages node['nagios']['php_packages']
23
+ end
24
+
25
+ apache2_install 'nagios' do
26
+ listen node['nagios']['enable_ssl'] ? %w(80 443) : %w(80)
27
+ mpm node['nagios']['apache_mpm']
28
+ end
29
+
30
+ apache2_module 'cgi'
31
+ apache2_module 'rewrite'
32
+ if apache_mod_php_supported?
33
+ apache2_mod_php 'nagios'
34
+ apache_php_handler = 'application/x-httpd-php'
35
+ else
36
+ apache2_module 'proxy'
37
+ apache2_module 'proxy_fcgi'
38
+ apache2_mod_proxy 'proxy'
39
+ php_fpm_pool 'nagios' do
40
+ user default_apache_user
41
+ group default_apache_group
42
+ listen_user default_apache_user
43
+ listen_group default_apache_group
44
+ end
45
+ apache_php_handler = "proxy:unix:#{php_fpm_socket}|fcgi://localhost"
46
+ end
47
+
48
+ apache2_module 'ssl' if node['nagios']['enable_ssl']
49
+
50
+ apache2_site '000-default' do
51
+ action :disable
52
+ notifies :reload, 'apache2_service[nagios]'
53
+ end
54
+
55
+ template "#{apache_dir}/sites-available/#{node['nagios']['server']['vname']}.conf" do
56
+ source 'apache2.conf.erb'
57
+ mode '0644'
58
+ variables(
59
+ nagios_url: node['nagios']['url'],
60
+ https: node['nagios']['enable_ssl'],
61
+ ssl_cert_file: node['nagios']['ssl_cert_file'],
62
+ ssl_cert_key: node['nagios']['ssl_cert_key'],
63
+ apache_log_dir: default_log_dir,
64
+ apache_php_handler: apache_php_handler
65
+ )
66
+ notifies :restart, 'apache2_service[nagios]' if File.symlink?("#{apache_dir}/sites-enabled/#{node['nagios']['server']['vname']}.conf")
67
+ end
68
+
69
+ file "#{apache_dir}/conf.d/#{node['nagios']['server']['vname']}.conf" do
70
+ action :delete
71
+ end
72
+
73
+ apache2_site node['nagios']['server']['vname']
74
+
75
+ node.default['nagios']['web_user'] = default_apache_user
76
+ node.default['nagios']['web_group'] = default_apache_group
77
+
78
+ # configure the appropriate authentication method for the web server
79
+ case node['nagios']['server_auth_method']
80
+ when 'openid'
81
+ apache2_module 'auth_openid' do
82
+ notifies :reload, 'apache2_service[nagios]'
83
+ end
84
+ when 'cas'
85
+ apache2_module 'auth_cas' do
86
+ notifies :reload, 'apache2_service[nagios]'
87
+ end
88
+ when 'ldap'
89
+ package 'mod_ldap' if platform_family?('rhel')
90
+
91
+ %w(ldap authnz_ldap).each do |m|
92
+ apache2_module m do
93
+ notifies :reload, 'apache2_service[nagios]'
94
+ end
95
+ end
96
+ when 'htauth'
97
+ Chef::Log.info('Authentication method htauth configured in server.rb')
98
+ else
99
+ Chef::Log.info('Default method htauth configured in server.rb')
100
+ end
101
+
102
+ apache2_service 'nagios' do
103
+ action [:enable, :start]
104
+ subscribes :restart, 'apache2_install[nagios]'
105
+ subscribes :reload, 'apache2_module[cgi]'
106
+ subscribes :reload, 'apache2_module[rewrite]'
107
+ subscribes :reload, 'apache2_mod_php[nagios]' if apache_mod_php_supported?
108
+ subscribes :reload, 'apache2_module[proxy]' unless apache_mod_php_supported?
109
+ subscribes :reload, 'apache2_module[proxy_fcgi]' unless apache_mod_php_supported?
110
+ subscribes :reload, 'apache2_mod_proxy[proxy]' unless apache_mod_php_supported?
111
+ subscribes :reload, 'apache2_module[ssl]' if node['nagios']['enable_ssl']
112
+ end
113
+
114
+ include_recipe 'nagios::server'
@@ -0,0 +1,41 @@
1
+ #
2
+ # Author:: Joshua Sierles <joshua@37signals.com>
3
+ # Author:: Joshua Timberman <joshua@chef.io>
4
+ # Author:: Nathan Haneysmith <nathan@chef.io>
5
+ # Author:: Seth Chisamore <schisamo@chef.io>
6
+ # Author:: Tim Smith <tsmith@chef.io>
7
+ # Cookbook:: nagios
8
+ # Recipe:: default
9
+ #
10
+ # Copyright:: 2009, 37signals
11
+ # Copyright 2009-2016, Chef Software, Inc.
12
+ # Copyright 2013-2014, Limelight Networks, Inc.
13
+ #
14
+ # Licensed under the Apache License, Version 2.0 (the "License");
15
+ # you may not use this file except in compliance with the License.
16
+ # You may obtain a copy of the License at
17
+ #
18
+ # http://www.apache.org/licenses/LICENSE-2.0
19
+ #
20
+ # Unless required by applicable law or agreed to in writing, software
21
+ # distributed under the License is distributed on an "AS IS" BASIS,
22
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
+ # See the License for the specific language governing permissions and
24
+ # limitations under the License.
25
+
26
+ # configure either Apache2 or NGINX
27
+ case node['nagios']['server']['web_server']
28
+ when 'nginx'
29
+ Chef::Log.info 'Setting up Nagios server via NGINX'
30
+ include_recipe 'nagios::nginx'
31
+ when 'apache'
32
+ Chef::Log.info 'Setting up Nagios server via Apache2'
33
+ include_recipe 'nagios::apache'
34
+ when 'none'
35
+ Chef::Log.info 'Setting up Nagios server without web server'
36
+ include_recipe 'nagios::server'
37
+ else
38
+ Chef::Log.fatal('Unknown web server option provided for Nagios server: ' \
39
+ "#{node['nagios']['server']['web_server']} provided. Allowed:" \
40
+ "'nginx', 'apache', or 'none'")
41
+ end
@@ -0,0 +1,114 @@
1
+ #
2
+ # Author:: Tim Smith <tsmith@chef.io>
3
+ # Cookbook:: nagios
4
+ # Recipe:: nginx
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ node.default['nagios']['server']['web_server'] = 'nginx'
19
+
20
+ nginx_install 'nagios' do
21
+ source platform_family?('rhel') ? 'epel' : 'distro'
22
+ ohai_plugin_enabled false
23
+ end
24
+
25
+ nginx_config 'nagios' do
26
+ default_site_enabled false
27
+ notifies :restart, 'nginx_service[nagios]', :delayed
28
+ end
29
+
30
+ php_install 'nagios'
31
+
32
+ php_fpm_pool 'nagios' do
33
+ user nagios_nginx_user
34
+ group nagios_nginx_group
35
+ listen_user nagios_nginx_user
36
+ listen_group nagios_nginx_group
37
+ end
38
+
39
+ package nagios_array(node['nagios']['server']['nginx_dispatch']['packages'])
40
+
41
+ if platform_family?('rhel')
42
+ template '/etc/sysconfig/spawn-fcgi' do
43
+ source 'spawn-fcgi.erb'
44
+ notifies :start, 'service[spawn-fcgi]', :delayed
45
+ variables(
46
+ nginx_user: nagios_nginx_user
47
+ )
48
+ end
49
+ end
50
+
51
+ nagios_array(node['nagios']['server']['nginx_dispatch']['services']).each do |svc|
52
+ service svc do
53
+ action [:enable, :start]
54
+ end
55
+ end
56
+
57
+ dispatch_type = node['nagios']['server']['nginx_dispatch']['type']
58
+
59
+ nginx_site 'nagios' do
60
+ template 'nginx.conf.erb'
61
+ cookbook 'nagios'
62
+ variables(
63
+ allowed_ips: node['nagios']['allowed_ips'],
64
+ cgi: %w(cgi both).include?(dispatch_type),
65
+ cgi_bin_dir: platform_family?('rhel') ? '/usr/lib64' : '/usr/lib',
66
+ chef_env: node.chef_environment == '_default' ? 'default' : node.chef_environment,
67
+ docroot: node['nagios']['docroot'],
68
+ fqdn: node['fqdn'],
69
+ htpasswd_file: File.join(node['nagios']['conf_dir'], 'htpasswd.users'),
70
+ https: node['nagios']['enable_ssl'],
71
+ listen_port: node['nagios']['http_port'],
72
+ log_dir: node['nagios']['log_dir'],
73
+ nagios_url: node['nagios']['url'],
74
+ nginx_dispatch_cgi_url: node['nagios']['server']['nginx_dispatch']['cgi_url'],
75
+ nginx_dispatch_php_url: "unix:#{php_fpm_socket}",
76
+ php: %w(php both).include?(dispatch_type),
77
+ public_domain: node['public_domain'] || node['domain'],
78
+ server_name: node['nagios']['server']['name'],
79
+ server_vname: node['nagios']['server']['vname'],
80
+ ssl_cert_file: node['nagios']['ssl_cert_file'],
81
+ ssl_cert_key: node['nagios']['ssl_cert_key']
82
+ )
83
+ notifies :reload, 'nginx_service[nagios]', :delayed
84
+ action [:create, :enable]
85
+ end
86
+
87
+ nginx_service 'nagios' do
88
+ action :enable
89
+ delayed_action :start
90
+ end
91
+
92
+ node.default['nagios']['web_user'] = nagios_nginx_user
93
+ node.default['nagios']['web_group'] = nagios_nginx_user
94
+
95
+ # configure the appropriate authentication method for the web server
96
+ case node['nagios']['server_auth_method']
97
+ when 'openid'
98
+ Chef::Log.fatal('OpenID authentication for Nagios is not supported on NGINX')
99
+ Chef::Log.fatal("Set node['nagios']['server_auth_method'] attribute in your Nagios role")
100
+ raise 'OpenID authentication not supported on NGINX'
101
+ when 'cas'
102
+ Chef::Log.fatal('CAS authentication for Nagios is not supported on NGINX')
103
+ Chef::Log.fatal("Set node['nagios']['server_auth_method'] attribute in your Nagios role")
104
+ raise 'CAS authentivation not supported on NGINX'
105
+ when 'ldap'
106
+ Chef::Log.fatal('LDAP authentication for Nagios is not supported on NGINX')
107
+ Chef::Log.fatal("Set node['nagios']['server_auth_method'] attribute in your Nagios role")
108
+ raise 'LDAP authentication not supported on NGINX'
109
+ else
110
+ # setup htpasswd auth
111
+ Chef::Log.info('Default method htauth configured in server.rb')
112
+ end
113
+
114
+ include_recipe 'nagios::server'