cloud-mu 3.6.10 → 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.
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 +2 -2
  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 -48
  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,95 @@
1
+ #
2
+ # Author:: Jake Vanderdray <jvanderdray@customink.com>
3
+ # Author:: Tim Smith <tsmith@chef.io>
4
+ # Cookbook:: nagios
5
+ # Recipe:: pagerduty
6
+ #
7
+ # Copyright:: 2011, CustomInk LLC
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+
21
+ include_recipe 'nagios::server_package'
22
+
23
+ package nagios_pagerduty_packages
24
+
25
+ remote_file "#{node['nagios']['plugin_dir']}/notify_pagerduty.pl" do
26
+ owner 'root'
27
+ group 'root'
28
+ mode '0755'
29
+ source node['nagios']['pagerduty']['script_url']
30
+ action :create_if_missing
31
+ end
32
+
33
+ template "#{node['nagios']['cgi-bin']}/pagerduty.cgi" do
34
+ source 'pagerduty.cgi.erb'
35
+ owner node['nagios']['user']
36
+ group node['nagios']['group']
37
+ mode '0755'
38
+ variables(
39
+ command_file: node['nagios']['conf']['command_file']
40
+ )
41
+ end
42
+
43
+ nagios_bags = NagiosDataBags.new
44
+ pagerduty_contacts = nagios_bags.get('nagios_pagerduty')
45
+
46
+ nagios_command 'notify-service-by-pagerduty' do
47
+ if node['nagios']['pagerduty']['proxy_url'].nil?
48
+ options 'command_line' => ::File.join(node['nagios']['plugin_dir'], 'notify_pagerduty.pl') + ' enqueue -f pd_nagios_object=service -f pd_description="$HOSTNAME$ : $SERVICEDESC$"'
49
+ else
50
+ options 'command_line' => ::File.join(node['nagios']['plugin_dir'], 'notify_pagerduty.pl') + ' enqueue -f pd_nagios_object=service -f pd_description="$HOSTNAME$ : $SERVICEDESC$"' + " --proxy #{node['nagios']['pagerduty']['proxy_url']}"
51
+ end
52
+ end
53
+
54
+ nagios_command 'notify-host-by-pagerduty' do
55
+ if node['nagios']['pagerduty']['proxy_url'].nil?
56
+ options 'command_line' => ::File.join(node['nagios']['plugin_dir'], 'notify_pagerduty.pl') + ' enqueue -f pd_nagios_object=host -f pd_description="$HOSTNAME$ : $SERVICEDESC$"'
57
+ else
58
+ options 'command_line' => ::File.join(node['nagios']['plugin_dir'], 'notify_pagerduty.pl') + ' enqueue -f pd_nagios_object=host -f pd_description="$HOSTNAME$ : $SERVICEDESC$"' + " --proxy #{node['nagios']['pagerduty']['proxy_url']}"
59
+ end
60
+ end
61
+
62
+ unless node['nagios']['pagerduty']['key'].nil? || node['nagios']['pagerduty']['key'].empty?
63
+ nagios_contact 'pagerduty' do
64
+ options 'alias' => 'PagerDuty Pseudo-Contact',
65
+ 'service_notification_period' => '24x7',
66
+ 'host_notification_period' => '24x7',
67
+ 'service_notification_options' => node['nagios']['pagerduty']['service_notification_options'],
68
+ 'host_notification_options' => node['nagios']['pagerduty']['host_notification_options'],
69
+ 'service_notification_commands' => 'notify-service-by-pagerduty',
70
+ 'host_notification_commands' => 'notify-host-by-pagerduty',
71
+ 'pager' => node['nagios']['pagerduty']['key']
72
+ end
73
+ end
74
+
75
+ pagerduty_contacts.each do |contact|
76
+ name = contact['contact'] || contact['id']
77
+
78
+ nagios_contact name do
79
+ options 'alias' => "PagerDuty Pseudo-Contact #{name}",
80
+ 'service_notification_period' => contact['service_notification_period'] || '24x7',
81
+ 'host_notification_period' => contact['host_notification_period'] || '24x7',
82
+ 'service_notification_options' => contact['service_notification_options'] || 'w,u,c,r',
83
+ 'host_notification_options' => contact['host_notification_options'] || 'd,r',
84
+ 'service_notification_commands' => 'notify-service-by-pagerduty',
85
+ 'host_notification_commands' => 'notify-host-by-pagerduty',
86
+ 'pager' => contact['key'] || contact['pagerduty_key'],
87
+ 'contactgroups' => contact['contactgroups']
88
+ end
89
+ end
90
+
91
+ cron 'Flush Pagerduty' do
92
+ user node['nagios']['user']
93
+ mailto 'root@localhost'
94
+ command "#{::File.join(node['nagios']['plugin_dir'], 'notify_pagerduty.pl')} flush"
95
+ end
@@ -0,0 +1,182 @@
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:: server
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
+ # (COOK-2350) workaround to allow for a nagios server install from source using
27
+ # (COOK-2350) the override attribute on debian/ubuntu
28
+ nagios_service_name = if platform_family?('debian') &&
29
+ node['nagios']['server']['install_method'] == 'source'
30
+ node['nagios']['server']['name']
31
+ else
32
+ node['nagios']['server']['service_name']
33
+ end
34
+
35
+ # install nagios service either from source of package
36
+ include_recipe "nagios::server_#{node['nagios']['server']['install_method']}"
37
+
38
+ # use the users_helper.rb library to build arrays of users and contacts
39
+ nagios_users = NagiosUsers.new(node)
40
+
41
+ if nagios_users.users.empty?
42
+ Chef::Log.fatal('Could not find users in the ' \
43
+ "\"#{node['nagios']['users_databag']}\"" \
44
+ "databag with the \"#{node['nagios']['users_databag_group']}\"" \
45
+ ' group. Users must be defined to allow for logins to the UI. ' \
46
+ 'Make sure the databag exists and, if you have set the ' \
47
+ '"users_databag_group", that users in that group exist.')
48
+ end
49
+
50
+ if node['nagios']['server_auth_method'] == 'htauth'
51
+ # setup htpasswd auth
52
+ directory node['nagios']['conf_dir']
53
+
54
+ template "#{node['nagios']['conf_dir']}/htpasswd.users" do
55
+ cookbook node['nagios']['htauth']['template_cookbook']
56
+ source node['nagios']['htauth']['template_file']
57
+ owner node['nagios']['user']
58
+ group node['nagios']['web_group']
59
+ mode '0640'
60
+ variables(nagios_users: nagios_users.users)
61
+ end
62
+ end
63
+
64
+ # Setting all general options
65
+ unless node['nagios'].nil?
66
+ unless node['nagios']['server'].nil?
67
+ Nagios.instance.normalize_hostname =
68
+ node['nagios']['server']['normalize_hostname']
69
+ end
70
+ end
71
+
72
+ Nagios.instance.host_name_attribute = node['nagios']['host_name_attribute']
73
+
74
+ # loading default configuration data
75
+ if node['nagios']['server']['load_default_config']
76
+ include_recipe 'nagios::_load_default_config'
77
+ end
78
+
79
+ # loading all databag configurations
80
+ if node['nagios']['server']['load_databag_config']
81
+ include_recipe 'nagios::_load_databag_config'
82
+ end
83
+
84
+ directory "#{node['nagios']['conf_dir']}/dist" do
85
+ owner node['nagios']['user']
86
+ group node['nagios']['group']
87
+ mode '0755'
88
+ end
89
+
90
+ # Don't run on RHEL since the state directory is the same as the log directory and causes idempotency issues
91
+ directory node['nagios']['state_dir'] do
92
+ owner node['nagios']['user']
93
+ group node['nagios']['group']
94
+ mode '0751'
95
+ end unless platform_family?('rhel')
96
+
97
+ directory "#{node['nagios']['state_dir']}/rw" do
98
+ owner node['nagios']['user']
99
+ group node['nagios']['web_group']
100
+ mode '2710'
101
+ end
102
+
103
+ cfg_files =
104
+ "#{node['nagios']['config_dir']}/*_#{node['nagios']['server']['name']}*.cfg"
105
+ execute 'archive-default-nagios-object-definitions' do
106
+ command "mv #{cfg_files} #{node['nagios']['conf_dir']}/dist"
107
+ not_if { Dir.glob(cfg_files).empty? }
108
+ end
109
+
110
+ directory "#{node['nagios']['conf_dir']}/certificates" do
111
+ owner node['nagios']['web_user']
112
+ group node['nagios']['web_group']
113
+ mode '0700'
114
+ end
115
+
116
+ ssl_code = "umask 077
117
+ openssl genrsa 2048 > nagios-server.key
118
+ openssl req -subj #{node['nagios']['ssl_req']} -new -x509 -nodes -sha1 \
119
+ -days 3650 -key nagios-server.key > nagios-server.crt
120
+ cat nagios-server.key nagios-server.crt > nagios-server.pem"
121
+
122
+ bash 'Create SSL Certificates' do
123
+ cwd "#{node['nagios']['conf_dir']}/certificates"
124
+ code ssl_code
125
+ not_if { ::File.exist?(node['nagios']['ssl_cert_file']) }
126
+ end
127
+
128
+ nagios_conf node['nagios']['server']['name'] do
129
+ config_subdir false
130
+ cookbook node['nagios']['nagios_config']['template_cookbook']
131
+ source node['nagios']['nagios_config']['template_file']
132
+ variables(nagios_config: node['nagios']['conf'])
133
+ end
134
+
135
+ nagios_conf 'cgi' do
136
+ config_subdir false
137
+ cookbook node['nagios']['cgi']['template_cookbook']
138
+ source node['nagios']['cgi']['template_file']
139
+ variables(nagios_service_name: nagios_service_name)
140
+ end
141
+
142
+ # resource.cfg differs on RPM and tarball based systems
143
+ if platform_family?('rhel')
144
+ template "#{node['nagios']['resource_dir']}/resource.cfg" do
145
+ cookbook node['nagios']['resources']['template_cookbook']
146
+ source node['nagios']['resources']['template_file']
147
+ owner node['nagios']['user']
148
+ group node['nagios']['group']
149
+ mode '0600'
150
+ end
151
+
152
+ directory node['nagios']['resource_dir'] do
153
+ owner 'root'
154
+ group node['nagios']['group']
155
+ mode '0755'
156
+ end
157
+ end
158
+
159
+ nagios_conf 'timeperiods'
160
+ nagios_conf 'contacts'
161
+ nagios_conf 'commands'
162
+ nagios_conf 'hosts'
163
+ nagios_conf 'hostgroups'
164
+ nagios_conf 'templates'
165
+ nagios_conf 'services'
166
+ nagios_conf 'servicegroups'
167
+ nagios_conf 'servicedependencies'
168
+
169
+ service 'nagios' do
170
+ service_name nagios_service_name
171
+ if ::File.exist?("#{nagios_config_dir}/services.cfg")
172
+ action [:enable, :start]
173
+ else
174
+ action :enable
175
+ end
176
+ end
177
+
178
+ # Remove distribution included config files that aren't managed via this cookbook
179
+ zap_directory nagios_distro_config_dir do
180
+ pattern '*.cfg'
181
+ only_if { ::Dir.exist?(nagios_distro_config_dir) }
182
+ end
@@ -0,0 +1,85 @@
1
+ #
2
+ # Author:: Seth Chisamore <schisamo@chef.io>
3
+ # Author:: Tim Smith <tsmith@chef.io>
4
+ # Cookbook:: nagios
5
+ # Recipe:: server_package
6
+ #
7
+ # Copyright:: 2011-2016, Chef Software, Inc.
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+
22
+ case node['platform_family']
23
+ when 'rhel'
24
+ include_recipe 'yum-epel' if node['nagios']['server']['install_yum-epel']
25
+ when 'debian'
26
+ # Nagios package requires to enter the admin password
27
+ # We generate it randomly as it's overwritten later in the config templates
28
+ random_initial_password = rand(36**16).to_s(36)
29
+
30
+ %w(adminpassword adminpassword-repeat).each do |setting|
31
+ execute "debconf-set-selections::#{node['nagios']['server']['vname']}-cgi::#{node['nagios']['server']['vname']}/#{setting}" do
32
+ command "echo #{node['nagios']['server']['vname']}-cgi #{node['nagios']['server']['vname']}/#{setting} password #{random_initial_password} | debconf-set-selections"
33
+ sensitive true
34
+ not_if "dpkg -l #{node['nagios']['server']['vname']}"
35
+ end
36
+ end
37
+ end
38
+
39
+ package node['nagios']['server']['packages']
40
+
41
+ # File typically exists on Debian
42
+ file "#{apache_dir}/conf-enabled/#{node['nagios']['server']['vname']}-cgi.conf" do
43
+ manage_symlink_source true
44
+ action :delete
45
+ end
46
+
47
+ # File typically exists on RHEL
48
+ file "#{apache_dir}/conf.d/nagios.conf" do
49
+ action :delete
50
+ end
51
+
52
+ directory node['nagios']['config_dir'] do
53
+ owner 'root'
54
+ group 'root'
55
+ mode '0755'
56
+ recursive true
57
+ end
58
+
59
+ directory node['nagios']['conf']['check_result_path'] do
60
+ owner node['nagios']['user']
61
+ group node['nagios']['group']
62
+ mode '0755'
63
+ recursive true
64
+ end
65
+
66
+ %w( cache_dir log_dir run_dir ).each do |dir|
67
+ directory node['nagios'][dir] do
68
+ recursive true
69
+ owner node['nagios']['user']
70
+ group node['nagios']['group']
71
+ mode '0755'
72
+ end
73
+ end
74
+
75
+ directory ::File.join(node['nagios']['log_dir'], 'archives') do
76
+ owner node['nagios']['user']
77
+ group node['nagios']['group']
78
+ mode '0755'
79
+ end
80
+
81
+ directory "/usr/lib/#{node['nagios']['server']['vname']}" do
82
+ owner node['nagios']['user']
83
+ group node['nagios']['group']
84
+ mode '0755'
85
+ end
@@ -0,0 +1,137 @@
1
+ #
2
+ # Author:: Seth Chisamore <schisamo@chef.io>
3
+ # Author:: Tim Smith <tsmith@chef.io>
4
+ # Cookbook:: nagios
5
+ # Recipe:: server_source
6
+ #
7
+ # Copyright:: 2011-2016, Chef Software, Inc.
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+
22
+ # Package pre-reqs
23
+ build_essential 'install compilation tools'
24
+
25
+ php_install 'nagios' do
26
+ packages node['nagios']['php_packages']
27
+ end
28
+
29
+ package node['nagios']['php_gd_package']
30
+
31
+ # the source install of nagios from this recipe does not include embedded perl support
32
+ # so unless the user explicitly set the p1_file attribute, we want to clear it
33
+ # Note: the cookbook now defaults to Nagios 4.X which doesn't support embedded perl anyways
34
+ node.default['nagios']['conf']['p1_file'] = nil
35
+
36
+ package node['nagios']['server']['dependencies']
37
+
38
+ user node['nagios']['user'] do
39
+ action :create
40
+ end
41
+
42
+ web_srv = node['nagios']['server']['web_server']
43
+
44
+ group node['nagios']['group'] do
45
+ members [
46
+ node['nagios']['user'],
47
+ web_srv == 'nginx' ? nginx_user : default_apache_user,
48
+ ]
49
+ action :create
50
+ end
51
+
52
+ nagios_version = node['nagios']['server']['version']
53
+
54
+ node['nagios']['server']['patches'].each do |patch|
55
+ remote_file "#{Chef::Config[:file_cache_path]}/#{patch}" do
56
+ source "#{node['nagios']['server']['patch_url']}/#{patch}"
57
+ end
58
+ end
59
+
60
+ remote_file 'nagios source file' do
61
+ path ::File.join(Chef::Config[:file_cache_path], "nagios-#{nagios_version}.tar.gz")
62
+ source node['nagios']['server']['source_url']
63
+ checksum node['nagios']['server']['checksum']
64
+ notifies :run, 'execute[compile-nagios]', :immediately
65
+ end
66
+
67
+ execute 'compile-nagios' do
68
+ cwd Chef::Config[:file_cache_path]
69
+ command <<-EOH
70
+ tar xzf nagios-#{nagios_version}.tar.gz
71
+ cd nagios-#{nagios_version}
72
+ ./configure --prefix=/usr \
73
+ --mandir=/usr/share/man \
74
+ --bindir=/usr/sbin \
75
+ --sbindir=#{node['nagios']['cgi-bin']} \
76
+ --datadir=#{node['nagios']['docroot']} \
77
+ --sysconfdir=#{node['nagios']['conf_dir']} \
78
+ --infodir=/usr/share/info \
79
+ --libexecdir=#{node['nagios']['plugin_dir']} \
80
+ --localstatedir=#{node['nagios']['state_dir']} \
81
+ --with-cgibindir=#{node['nagios']['cgi-bin']} \
82
+ --enable-event-broker \
83
+ --with-nagios-user=#{node['nagios']['user']} \
84
+ --with-nagios-group=#{node['nagios']['group']} \
85
+ --with-command-user=#{node['nagios']['user']} \
86
+ --with-command-group=#{node['nagios']['group']} \
87
+ --with-init-dir=/etc/init.d \
88
+ --with-lockfile=#{node['nagios']['run_dir']}/#{node['nagios']['server']['vname']}.pid \
89
+ --with-mail=/usr/bin/mail \
90
+ --with-perlcache \
91
+ --with-htmurl=/ \
92
+ --with-cgiurl=#{node['nagios']['cgi-path']}
93
+ make all
94
+ make install
95
+ make install-cgis
96
+ make install-init
97
+ make install-config
98
+ make install-commandmode
99
+ #{node['nagios']['source']['add_build_commands'].join("\n")}
100
+ EOH
101
+ action :nothing
102
+ end
103
+
104
+ directory node['nagios']['config_dir'] do
105
+ owner 'root'
106
+ group 'root'
107
+ mode '0755'
108
+ recursive true
109
+ end
110
+
111
+ directory node['nagios']['conf']['check_result_path'] do
112
+ owner node['nagios']['user']
113
+ group node['nagios']['group']
114
+ mode '0755'
115
+ recursive true
116
+ end
117
+
118
+ %w(cache_dir log_dir run_dir).each do |dir|
119
+ directory node['nagios'][dir] do
120
+ recursive true
121
+ owner node['nagios']['user']
122
+ group node['nagios']['group']
123
+ mode '0755'
124
+ end
125
+ end
126
+
127
+ directory ::File.join(node['nagios']['log_dir'], 'archives') do
128
+ owner node['nagios']['user']
129
+ group node['nagios']['group']
130
+ mode '0755'
131
+ end
132
+
133
+ directory "/usr/lib/#{node['nagios']['server']['vname']}" do
134
+ owner node['nagios']['user']
135
+ group node['nagios']['group']
136
+ mode '0755'
137
+ end
@@ -0,0 +1,34 @@
1
+ #
2
+ # Author:: Sander Botman <sbotman@schubergphilis.com>
3
+ # Cookbook:: : nagios
4
+ # Resource:: : command
5
+ #
6
+ # Copyright:: 2015, 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
+ property :options, [Hash, Chef::DataBagItem], default: {}
21
+ unified_mode true
22
+
23
+ action :create do
24
+ o = Nagios::Command.create(new_resource.name)
25
+ o.import(new_resource.options)
26
+ end
27
+
28
+ action :delete do
29
+ Nagios.instance.delete('command', new_resource.name)
30
+ end
31
+
32
+ action_class do
33
+ require_relative '../libraries/command'
34
+ end
@@ -0,0 +1,52 @@
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
+ # Cookbook:: nagios
7
+ # Resource:: nagios_conf
8
+ #
9
+ # Copyright:: 2009, 37signals
10
+ # Copyright:: 2009-2016, Chef Software, Inc.
11
+ #
12
+ # Licensed under the Apache License, Version 2.0 (the "License");
13
+ # you may not use this file except in compliance with the License.
14
+ # You may obtain a copy of the License at
15
+ #
16
+ # http://www.apache.org/licenses/LICENSE-2.0
17
+ #
18
+ # Unless required by applicable law or agreed to in writing, software
19
+ # distributed under the License is distributed on an "AS IS" BASIS,
20
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ # See the License for the specific language governing permissions and
22
+ # limitations under the License.
23
+ #
24
+ property :variables, Hash, default: {}
25
+ property :config_subdir, [true, false], default: true
26
+ property :source, String
27
+ property :cookbook, String, default: 'nagios'
28
+ unified_mode true
29
+
30
+ action :create do
31
+ conf_dir = new_resource.config_subdir ? node['nagios']['config_dir'] : node['nagios']['conf_dir']
32
+ source ||= "#{new_resource.name}.cfg.erb"
33
+
34
+ with_run_context(:root) do
35
+ template "#{conf_dir}/#{new_resource.name}.cfg" do
36
+ cookbook new_resource.cookbook if new_resource.cookbook
37
+ owner 'nagios'
38
+ group 'nagios'
39
+ source source
40
+ mode '0644'
41
+ variables new_resource.variables
42
+ notifies :restart, 'service[nagios]'
43
+ backup 0
44
+ action :nothing
45
+ delayed_action :create
46
+ end
47
+ end
48
+ end
49
+
50
+ action_class do
51
+ require_relative '../libraries/nagios'
52
+ end
@@ -0,0 +1,34 @@
1
+ #
2
+ # Author:: Sander Botman <sbotman@schubergphilis.com>
3
+ # Cookbook:: : nagios
4
+ # Resource:: : contact
5
+ #
6
+ # Copyright:: 2015, 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
+ property :options, [Hash, Chef::DataBagItem], default: {}
21
+ unified_mode true
22
+
23
+ action :create do
24
+ o = Nagios::Contact.create(new_resource.name)
25
+ o.import(new_resource.options)
26
+ end
27
+
28
+ action :delete do
29
+ Nagios.instance.delete('contact', new_resource.name)
30
+ end
31
+
32
+ action_class do
33
+ require_relative '../libraries/contact'
34
+ end
@@ -0,0 +1,35 @@
1
+ #
2
+ # Author:: Sander Botman <sbotman@schubergphilis.com>
3
+ # Cookbook:: nagios
4
+ # Resource:: contactgroup
5
+ #
6
+ # Copyright:: 2015, 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
+
21
+ property :options, [Hash, Chef::DataBagItem], default: {}
22
+ unified_mode true
23
+
24
+ action :create do
25
+ o = Nagios::Contactgroup.create(new_resource.name)
26
+ o.import(new_resource.options)
27
+ end
28
+
29
+ action :delete do
30
+ Nagios.instance.delete('contactgroup', new_resource.name)
31
+ end
32
+
33
+ action_class do
34
+ require_relative '../libraries/contactgroup'
35
+ end