cloud-mu 2.1.0beta → 3.0.0beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (291) hide show
  1. checksums.yaml +5 -5
  2. data/Berksfile +4 -5
  3. data/Berksfile.lock +179 -0
  4. data/README.md +1 -6
  5. data/ansible/roles/geerlingguy.firewall/templates/firewall.bash.j2 +0 -0
  6. data/ansible/roles/mu-installer/README.md +33 -0
  7. data/ansible/roles/mu-installer/defaults/main.yml +2 -0
  8. data/ansible/roles/mu-installer/handlers/main.yml +2 -0
  9. data/ansible/roles/mu-installer/meta/main.yml +60 -0
  10. data/ansible/roles/mu-installer/tasks/main.yml +13 -0
  11. data/ansible/roles/mu-installer/tests/inventory +2 -0
  12. data/ansible/roles/mu-installer/tests/test.yml +5 -0
  13. data/ansible/roles/mu-installer/vars/main.yml +2 -0
  14. data/bin/mu-adopt +125 -0
  15. data/bin/mu-aws-setup +4 -4
  16. data/bin/mu-azure-setup +265 -0
  17. data/bin/mu-azure-tests +43 -0
  18. data/bin/mu-cleanup +20 -8
  19. data/bin/mu-configure +224 -98
  20. data/bin/mu-deploy +8 -3
  21. data/bin/mu-gcp-setup +16 -8
  22. data/bin/mu-gen-docs +92 -8
  23. data/bin/mu-load-config.rb +52 -12
  24. data/bin/mu-momma-cat +36 -0
  25. data/bin/mu-node-manage +34 -27
  26. data/bin/mu-self-update +2 -2
  27. data/bin/mu-ssh +12 -8
  28. data/bin/mu-upload-chef-artifacts +11 -4
  29. data/bin/mu-user-manage +3 -0
  30. data/cloud-mu.gemspec +8 -11
  31. data/cookbooks/firewall/libraries/helpers_iptables.rb +2 -2
  32. data/cookbooks/firewall/metadata.json +1 -1
  33. data/cookbooks/firewall/recipes/default.rb +5 -9
  34. data/cookbooks/mu-firewall/attributes/default.rb +2 -0
  35. data/cookbooks/mu-firewall/metadata.rb +1 -1
  36. data/cookbooks/mu-glusterfs/templates/default/mu-gluster-client.erb +0 -0
  37. data/cookbooks/mu-master/Berksfile +2 -2
  38. data/cookbooks/mu-master/files/default/check_mem.pl +0 -0
  39. data/cookbooks/mu-master/files/default/cloudamatic.png +0 -0
  40. data/cookbooks/mu-master/metadata.rb +5 -4
  41. data/cookbooks/mu-master/recipes/389ds.rb +1 -1
  42. data/cookbooks/mu-master/recipes/basepackages.rb +30 -10
  43. data/cookbooks/mu-master/recipes/default.rb +59 -7
  44. data/cookbooks/mu-master/recipes/firewall-holes.rb +1 -1
  45. data/cookbooks/mu-master/recipes/init.rb +65 -47
  46. data/cookbooks/mu-master/recipes/{eks-kubectl.rb → kubectl.rb} +4 -10
  47. data/cookbooks/mu-master/recipes/sssd.rb +2 -1
  48. data/cookbooks/mu-master/recipes/update_nagios_only.rb +6 -6
  49. data/cookbooks/mu-master/templates/default/web_app.conf.erb +2 -2
  50. data/cookbooks/mu-master/templates/mods/ldap.conf.erb +4 -0
  51. data/cookbooks/mu-php54/Berksfile +1 -2
  52. data/cookbooks/mu-php54/metadata.rb +4 -5
  53. data/cookbooks/mu-php54/recipes/default.rb +1 -1
  54. data/cookbooks/mu-splunk/templates/default/splunk-init.erb +0 -0
  55. data/cookbooks/mu-tools/Berksfile +3 -2
  56. data/cookbooks/mu-tools/files/default/Mu_CA.pem +33 -0
  57. data/cookbooks/mu-tools/libraries/helper.rb +20 -8
  58. data/cookbooks/mu-tools/metadata.rb +5 -2
  59. data/cookbooks/mu-tools/recipes/apply_security.rb +2 -3
  60. data/cookbooks/mu-tools/recipes/eks.rb +1 -1
  61. data/cookbooks/mu-tools/recipes/gcloud.rb +5 -30
  62. data/cookbooks/mu-tools/recipes/nagios.rb +1 -1
  63. data/cookbooks/mu-tools/recipes/rsyslog.rb +1 -0
  64. data/cookbooks/mu-tools/recipes/selinux.rb +19 -0
  65. data/cookbooks/mu-tools/recipes/split_var_partitions.rb +0 -1
  66. data/cookbooks/mu-tools/recipes/windows-client.rb +256 -122
  67. data/cookbooks/mu-tools/resources/disk.rb +3 -1
  68. data/cookbooks/mu-tools/templates/amazon/sshd_config.erb +1 -1
  69. data/cookbooks/mu-tools/templates/default/etc_hosts.erb +1 -1
  70. data/cookbooks/mu-tools/templates/default/{kubeconfig.erb → kubeconfig-eks.erb} +0 -0
  71. data/cookbooks/mu-tools/templates/default/kubeconfig-gke.erb +27 -0
  72. data/cookbooks/mu-tools/templates/windows-10/sshd_config.erb +137 -0
  73. data/cookbooks/mu-utility/recipes/nat.rb +4 -0
  74. data/extras/alpha.png +0 -0
  75. data/extras/beta.png +0 -0
  76. data/extras/clean-stock-amis +2 -2
  77. data/extras/generate-stock-images +131 -0
  78. data/extras/git-fix-permissions-hook +0 -0
  79. data/extras/image-generators/AWS/centos6.yaml +17 -0
  80. data/extras/image-generators/{aws → AWS}/centos7-govcloud.yaml +0 -0
  81. data/extras/image-generators/{aws → AWS}/centos7.yaml +0 -0
  82. data/extras/image-generators/{aws → AWS}/rhel7.yaml +0 -0
  83. data/extras/image-generators/{aws → AWS}/win2k12.yaml +0 -0
  84. data/extras/image-generators/{aws → AWS}/win2k16.yaml +0 -0
  85. data/extras/image-generators/{aws → AWS}/windows.yaml +0 -0
  86. data/extras/image-generators/{gcp → Google}/centos6.yaml +1 -0
  87. data/extras/image-generators/Google/centos7.yaml +18 -0
  88. data/extras/python_rpm/build.sh +0 -0
  89. data/extras/release.png +0 -0
  90. data/extras/ruby_rpm/build.sh +0 -0
  91. data/extras/ruby_rpm/muby.spec +1 -1
  92. data/install/README.md +43 -5
  93. data/install/deprecated-bash-library.sh +0 -0
  94. data/install/installer +1 -1
  95. data/install/jenkinskeys.rb +0 -0
  96. data/install/mu-master.yaml +55 -0
  97. data/modules/mommacat.ru +41 -7
  98. data/modules/mu.rb +444 -149
  99. data/modules/mu/adoption.rb +500 -0
  100. data/modules/mu/cleanup.rb +235 -158
  101. data/modules/mu/cloud.rb +675 -138
  102. data/modules/mu/clouds/aws.rb +156 -24
  103. data/modules/mu/clouds/aws/alarm.rb +4 -14
  104. data/modules/mu/clouds/aws/bucket.rb +60 -18
  105. data/modules/mu/clouds/aws/cache_cluster.rb +8 -20
  106. data/modules/mu/clouds/aws/collection.rb +12 -22
  107. data/modules/mu/clouds/aws/container_cluster.rb +209 -118
  108. data/modules/mu/clouds/aws/database.rb +120 -45
  109. data/modules/mu/clouds/aws/dnszone.rb +7 -18
  110. data/modules/mu/clouds/aws/endpoint.rb +5 -15
  111. data/modules/mu/clouds/aws/firewall_rule.rb +144 -72
  112. data/modules/mu/clouds/aws/folder.rb +4 -11
  113. data/modules/mu/clouds/aws/function.rb +6 -16
  114. data/modules/mu/clouds/aws/group.rb +4 -12
  115. data/modules/mu/clouds/aws/habitat.rb +11 -13
  116. data/modules/mu/clouds/aws/loadbalancer.rb +40 -28
  117. data/modules/mu/clouds/aws/log.rb +5 -13
  118. data/modules/mu/clouds/aws/msg_queue.rb +9 -24
  119. data/modules/mu/clouds/aws/nosqldb.rb +4 -12
  120. data/modules/mu/clouds/aws/notifier.rb +6 -13
  121. data/modules/mu/clouds/aws/role.rb +69 -40
  122. data/modules/mu/clouds/aws/search_domain.rb +17 -20
  123. data/modules/mu/clouds/aws/server.rb +184 -94
  124. data/modules/mu/clouds/aws/server_pool.rb +33 -38
  125. data/modules/mu/clouds/aws/storage_pool.rb +5 -12
  126. data/modules/mu/clouds/aws/user.rb +59 -33
  127. data/modules/mu/clouds/aws/userdata/linux.erb +18 -30
  128. data/modules/mu/clouds/aws/userdata/windows.erb +9 -9
  129. data/modules/mu/clouds/aws/vpc.rb +214 -145
  130. data/modules/mu/clouds/azure.rb +978 -44
  131. data/modules/mu/clouds/azure/container_cluster.rb +413 -0
  132. data/modules/mu/clouds/azure/firewall_rule.rb +500 -0
  133. data/modules/mu/clouds/azure/habitat.rb +167 -0
  134. data/modules/mu/clouds/azure/loadbalancer.rb +205 -0
  135. data/modules/mu/clouds/azure/role.rb +211 -0
  136. data/modules/mu/clouds/azure/server.rb +810 -0
  137. data/modules/mu/clouds/azure/user.rb +257 -0
  138. data/modules/mu/clouds/azure/userdata/README.md +4 -0
  139. data/modules/mu/clouds/azure/userdata/linux.erb +137 -0
  140. data/modules/mu/clouds/azure/userdata/windows.erb +275 -0
  141. data/modules/mu/clouds/azure/vpc.rb +782 -0
  142. data/modules/mu/clouds/cloudformation.rb +12 -9
  143. data/modules/mu/clouds/cloudformation/firewall_rule.rb +5 -13
  144. data/modules/mu/clouds/cloudformation/server.rb +10 -1
  145. data/modules/mu/clouds/cloudformation/server_pool.rb +1 -0
  146. data/modules/mu/clouds/cloudformation/vpc.rb +0 -2
  147. data/modules/mu/clouds/google.rb +554 -117
  148. data/modules/mu/clouds/google/bucket.rb +173 -32
  149. data/modules/mu/clouds/google/container_cluster.rb +1112 -157
  150. data/modules/mu/clouds/google/database.rb +24 -47
  151. data/modules/mu/clouds/google/firewall_rule.rb +344 -89
  152. data/modules/mu/clouds/google/folder.rb +156 -79
  153. data/modules/mu/clouds/google/group.rb +272 -82
  154. data/modules/mu/clouds/google/habitat.rb +177 -52
  155. data/modules/mu/clouds/google/loadbalancer.rb +9 -34
  156. data/modules/mu/clouds/google/role.rb +1211 -0
  157. data/modules/mu/clouds/google/server.rb +491 -227
  158. data/modules/mu/clouds/google/server_pool.rb +233 -48
  159. data/modules/mu/clouds/google/user.rb +479 -125
  160. data/modules/mu/clouds/google/userdata/linux.erb +3 -3
  161. data/modules/mu/clouds/google/userdata/windows.erb +9 -9
  162. data/modules/mu/clouds/google/vpc.rb +381 -223
  163. data/modules/mu/config.rb +689 -214
  164. data/modules/mu/config/bucket.rb +1 -1
  165. data/modules/mu/config/cache_cluster.rb +1 -1
  166. data/modules/mu/config/cache_cluster.yml +0 -4
  167. data/modules/mu/config/container_cluster.rb +18 -9
  168. data/modules/mu/config/database.rb +6 -23
  169. data/modules/mu/config/firewall_rule.rb +9 -15
  170. data/modules/mu/config/folder.rb +22 -21
  171. data/modules/mu/config/habitat.rb +22 -21
  172. data/modules/mu/config/loadbalancer.rb +2 -2
  173. data/modules/mu/config/role.rb +9 -40
  174. data/modules/mu/config/server.rb +26 -5
  175. data/modules/mu/config/server_pool.rb +1 -1
  176. data/modules/mu/config/storage_pool.rb +2 -2
  177. data/modules/mu/config/user.rb +4 -0
  178. data/modules/mu/config/vpc.rb +350 -110
  179. data/modules/mu/defaults/{amazon_images.yaml → AWS.yaml} +37 -39
  180. data/modules/mu/defaults/Azure.yaml +17 -0
  181. data/modules/mu/defaults/Google.yaml +24 -0
  182. data/modules/mu/defaults/README.md +1 -1
  183. data/modules/mu/deploy.rb +168 -125
  184. data/modules/mu/groomer.rb +2 -1
  185. data/modules/mu/groomers/ansible.rb +104 -32
  186. data/modules/mu/groomers/chef.rb +96 -44
  187. data/modules/mu/kittens.rb +20602 -0
  188. data/modules/mu/logger.rb +38 -11
  189. data/modules/mu/master.rb +90 -8
  190. data/modules/mu/master/chef.rb +2 -3
  191. data/modules/mu/master/ldap.rb +0 -1
  192. data/modules/mu/master/ssl.rb +250 -0
  193. data/modules/mu/mommacat.rb +917 -513
  194. data/modules/scratchpad.erb +1 -1
  195. data/modules/tests/super_complex_bok.yml +0 -0
  196. data/modules/tests/super_simple_bok.yml +0 -0
  197. data/roles/mu-master.json +2 -1
  198. data/spec/azure_creds +5 -0
  199. data/spec/mu.yaml +56 -0
  200. data/spec/mu/clouds/azure_spec.rb +164 -27
  201. data/spec/spec_helper.rb +5 -0
  202. data/test/clean_up.py +0 -0
  203. data/test/exec_inspec.py +0 -0
  204. data/test/exec_mu_install.py +0 -0
  205. data/test/exec_retry.py +0 -0
  206. data/test/smoke_test.rb +0 -0
  207. metadata +90 -118
  208. data/cookbooks/mu-jenkins/Berksfile +0 -14
  209. data/cookbooks/mu-jenkins/CHANGELOG.md +0 -13
  210. data/cookbooks/mu-jenkins/LICENSE +0 -37
  211. data/cookbooks/mu-jenkins/README.md +0 -105
  212. data/cookbooks/mu-jenkins/attributes/default.rb +0 -42
  213. data/cookbooks/mu-jenkins/files/default/cleanup_deploy_config.xml +0 -73
  214. data/cookbooks/mu-jenkins/files/default/deploy_config.xml +0 -44
  215. data/cookbooks/mu-jenkins/metadata.rb +0 -21
  216. data/cookbooks/mu-jenkins/recipes/default.rb +0 -195
  217. data/cookbooks/mu-jenkins/recipes/node-ssh-config.rb +0 -54
  218. data/cookbooks/mu-jenkins/recipes/public_key.rb +0 -24
  219. data/cookbooks/mu-jenkins/templates/default/example_job.config.xml.erb +0 -24
  220. data/cookbooks/mu-jenkins/templates/default/org.jvnet.hudson.plugins.SSHBuildWrapper.xml.erb +0 -14
  221. data/cookbooks/mu-jenkins/templates/default/ssh_config.erb +0 -6
  222. data/cookbooks/nagios/Berksfile +0 -11
  223. data/cookbooks/nagios/CHANGELOG.md +0 -589
  224. data/cookbooks/nagios/CONTRIBUTING.md +0 -11
  225. data/cookbooks/nagios/LICENSE +0 -37
  226. data/cookbooks/nagios/README.md +0 -328
  227. data/cookbooks/nagios/TESTING.md +0 -2
  228. data/cookbooks/nagios/attributes/config.rb +0 -171
  229. data/cookbooks/nagios/attributes/default.rb +0 -228
  230. data/cookbooks/nagios/chefignore +0 -102
  231. data/cookbooks/nagios/definitions/command.rb +0 -33
  232. data/cookbooks/nagios/definitions/contact.rb +0 -33
  233. data/cookbooks/nagios/definitions/contactgroup.rb +0 -33
  234. data/cookbooks/nagios/definitions/host.rb +0 -33
  235. data/cookbooks/nagios/definitions/hostdependency.rb +0 -33
  236. data/cookbooks/nagios/definitions/hostescalation.rb +0 -34
  237. data/cookbooks/nagios/definitions/hostgroup.rb +0 -33
  238. data/cookbooks/nagios/definitions/nagios_conf.rb +0 -38
  239. data/cookbooks/nagios/definitions/resource.rb +0 -33
  240. data/cookbooks/nagios/definitions/service.rb +0 -33
  241. data/cookbooks/nagios/definitions/servicedependency.rb +0 -33
  242. data/cookbooks/nagios/definitions/serviceescalation.rb +0 -34
  243. data/cookbooks/nagios/definitions/servicegroup.rb +0 -33
  244. data/cookbooks/nagios/definitions/timeperiod.rb +0 -33
  245. data/cookbooks/nagios/libraries/base.rb +0 -314
  246. data/cookbooks/nagios/libraries/command.rb +0 -91
  247. data/cookbooks/nagios/libraries/contact.rb +0 -230
  248. data/cookbooks/nagios/libraries/contactgroup.rb +0 -112
  249. data/cookbooks/nagios/libraries/custom_option.rb +0 -36
  250. data/cookbooks/nagios/libraries/data_bag_helper.rb +0 -23
  251. data/cookbooks/nagios/libraries/default.rb +0 -90
  252. data/cookbooks/nagios/libraries/host.rb +0 -412
  253. data/cookbooks/nagios/libraries/hostdependency.rb +0 -181
  254. data/cookbooks/nagios/libraries/hostescalation.rb +0 -173
  255. data/cookbooks/nagios/libraries/hostgroup.rb +0 -119
  256. data/cookbooks/nagios/libraries/nagios.rb +0 -282
  257. data/cookbooks/nagios/libraries/resource.rb +0 -59
  258. data/cookbooks/nagios/libraries/service.rb +0 -455
  259. data/cookbooks/nagios/libraries/servicedependency.rb +0 -215
  260. data/cookbooks/nagios/libraries/serviceescalation.rb +0 -195
  261. data/cookbooks/nagios/libraries/servicegroup.rb +0 -144
  262. data/cookbooks/nagios/libraries/timeperiod.rb +0 -160
  263. data/cookbooks/nagios/libraries/users_helper.rb +0 -54
  264. data/cookbooks/nagios/metadata.rb +0 -25
  265. data/cookbooks/nagios/recipes/_load_databag_config.rb +0 -153
  266. data/cookbooks/nagios/recipes/_load_default_config.rb +0 -241
  267. data/cookbooks/nagios/recipes/apache.rb +0 -48
  268. data/cookbooks/nagios/recipes/default.rb +0 -204
  269. data/cookbooks/nagios/recipes/nginx.rb +0 -82
  270. data/cookbooks/nagios/recipes/pagerduty.rb +0 -143
  271. data/cookbooks/nagios/recipes/server_package.rb +0 -40
  272. data/cookbooks/nagios/recipes/server_source.rb +0 -164
  273. data/cookbooks/nagios/templates/default/apache2.conf.erb +0 -96
  274. data/cookbooks/nagios/templates/default/cgi.cfg.erb +0 -266
  275. data/cookbooks/nagios/templates/default/commands.cfg.erb +0 -13
  276. data/cookbooks/nagios/templates/default/contacts.cfg.erb +0 -37
  277. data/cookbooks/nagios/templates/default/hostgroups.cfg.erb +0 -25
  278. data/cookbooks/nagios/templates/default/hosts.cfg.erb +0 -15
  279. data/cookbooks/nagios/templates/default/htpasswd.users.erb +0 -6
  280. data/cookbooks/nagios/templates/default/nagios.cfg.erb +0 -22
  281. data/cookbooks/nagios/templates/default/nginx.conf.erb +0 -62
  282. data/cookbooks/nagios/templates/default/pagerduty.cgi.erb +0 -185
  283. data/cookbooks/nagios/templates/default/resource.cfg.erb +0 -27
  284. data/cookbooks/nagios/templates/default/servicedependencies.cfg.erb +0 -15
  285. data/cookbooks/nagios/templates/default/servicegroups.cfg.erb +0 -14
  286. data/cookbooks/nagios/templates/default/services.cfg.erb +0 -14
  287. data/cookbooks/nagios/templates/default/templates.cfg.erb +0 -31
  288. data/cookbooks/nagios/templates/default/timeperiods.cfg.erb +0 -13
  289. data/extras/image-generators/aws/centos6.yaml +0 -18
  290. data/modules/mu/defaults/google_images.yaml +0 -16
  291. data/roles/mu-master-jenkins.json +0 -24
@@ -1,33 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name : nagios
4
- # Definition : hostdependency
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
- define :nagios_hostdependency do
22
- params[:action] ||= :create
23
- params[:options] ||= {}
24
-
25
- if nagios_action_create?(params[:action])
26
- o = Nagios::Hostdependency.create(params[:name])
27
- o.import(params[:options])
28
- end
29
-
30
- if nagios_action_delete?(params[:action])
31
- Nagios.instance.delete('hostdependency', params[:name])
32
- end
33
- end
@@ -1,34 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name : nagios
4
- # Definition : hostescalation
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
- define :nagios_hostescalation do
22
- params[:action] ||= :create
23
- params[:options] ||= {}
24
-
25
- if nagios_action_create?(params[:action])
26
- o = Nagios::Hostescalation.new(params[:name])
27
- o.import(params[:options])
28
- Nagios.instance.push(o)
29
- end
30
-
31
- if nagios_action_delete?(params[:action])
32
- Nagios.instance.delete('hostescalation', params[:name])
33
- end
34
- end
@@ -1,33 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name : nagios
4
- # Definition : hostgroup
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
- define :nagios_hostgroup do
22
- params[:action] ||= :create
23
- params[:options] ||= {}
24
-
25
- if nagios_action_create?(params[:action])
26
- o = Nagios::Hostgroup.create(params[:name])
27
- o.import(params[:options])
28
- end
29
-
30
- if nagios_action_delete?(params[:action])
31
- Nagios.instance.delete('hostgroup', params[:name])
32
- end
33
- end
@@ -1,38 +0,0 @@
1
- #
2
- # Author:: Joshua Sierles <joshua@37signals.com>
3
- # Author:: Joshua Timberman <joshua@getchef.com>
4
- # Author:: Nathan Haneysmith <nathan@getchef.com>
5
- # Author:: Seth Chisamore <schisamo@getchef.com>
6
- # Cookbook Name:: nagios
7
- # Definition:: 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
- define :nagios_conf, variables: {}, config_subdir: true, source: nil do
25
- conf_dir = params[:config_subdir] ? node['nagios']['config_dir'] : node['nagios']['conf_dir']
26
- params[:source] ||= "#{params[:name]}.cfg.erb"
27
-
28
- template "#{conf_dir}/#{params[:name]}.cfg" do
29
- cookbook params[:cookbook] if params[:cookbook]
30
- owner node['nagios']['user']
31
- group node['nagios']['group']
32
- source params[:source]
33
- mode '0644'
34
- variables params[:variables]
35
- notifies :reload, 'service[nagios]'
36
- backup 0
37
- end
38
- end
@@ -1,33 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name : nagios
4
- # Definition : resource
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
- define :nagios_resource do
22
- params[:action] ||= :create
23
- params[:options] ||= {}
24
-
25
- if nagios_action_create?(params[:action])
26
- o = Nagios::Resource.create(params[:name])
27
- o.import(params[:options])
28
- end
29
-
30
- if nagios_action_delete?(params[:action])
31
- Nagios.instance.delete('resource', params[:name])
32
- end
33
- end
@@ -1,33 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name : nagios
4
- # Definition : service
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
- define :nagios_service do
22
- params[:action] ||= :create
23
- params[:options] ||= {}
24
-
25
- if nagios_action_create?(params[:action])
26
- o = Nagios::Service.create(params[:name])
27
- o.import(params[:options])
28
- end
29
-
30
- if nagios_action_delete?(params[:action])
31
- Nagios.instance.delete('service', params[:name])
32
- end
33
- end
@@ -1,33 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name : nagios
4
- # Definition : servicedependency
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
- define :nagios_servicedependency do
22
- params[:action] ||= :create
23
- params[:options] ||= {}
24
-
25
- if nagios_action_create?(params[:action])
26
- o = Nagios::Servicedependency.create(params[:name])
27
- o.import(params[:options])
28
- end
29
-
30
- if nagios_action_delete?(params[:action])
31
- Nagios.instance.delete('servicedependency', params[:name])
32
- end
33
- end
@@ -1,34 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name : nagios
4
- # Definition : serviceescalation
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
- define :nagios_serviceescalation do
22
- params[:action] ||= :create
23
- params[:options] ||= {}
24
-
25
- if nagios_action_create?(params[:action])
26
- o = Nagios::Serviceescalation.new(params[:name])
27
- o.import(params[:options])
28
- Nagios.instance.push(o)
29
- end
30
-
31
- if nagios_action_delete?(params[:action])
32
- Nagios.instance.delete('serviceescalation', params[:name])
33
- end
34
- end
@@ -1,33 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name : nagios
4
- # Definition : servicegroup
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
- define :nagios_servicegroup do
22
- params[:action] ||= :create
23
- params[:options] ||= {}
24
-
25
- if nagios_action_create?(params[:action])
26
- o = Nagios::Servicegroup.create(params[:name])
27
- o.import(params[:options])
28
- end
29
-
30
- if nagios_action_delete?(params[:action])
31
- Nagios.instance.delete('servicegroup', params[:name])
32
- end
33
- end
@@ -1,33 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name : nagios
4
- # Definition : timeperiod
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
- define :nagios_timeperiod do
22
- params[:action] ||= :create
23
- params[:options] ||= {}
24
-
25
- if nagios_action_create?(params[:action])
26
- o = Nagios::Timeperiod.create(params[:name])
27
- o.import(params[:options])
28
- end
29
-
30
- if nagios_action_delete?(params[:action])
31
- Nagios.instance.delete('timeperiod', params[:name])
32
- end
33
- end
@@ -1,314 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name:: nagios
4
- # Library:: base
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
-
21
- class Nagios
22
- # This class it the base for all other Nagios classes.
23
- # It provides common methods to prevent code duplication.
24
- class Base
25
- attr_accessor :register,
26
- :name,
27
- :use,
28
- :not_modifiers
29
-
30
- def initialize
31
- @add_modifiers = {}
32
- @not_modifiers = Hash.new { |h, k| h[k] = {} }
33
- end
34
-
35
- def merge!(obj)
36
- merge_members(obj)
37
- merge_attributes(obj)
38
- end
39
-
40
- def merge_members!(obj)
41
- merge_members(obj)
42
- end
43
-
44
- def register
45
- return @register if blank?(@name)
46
- 0
47
- end
48
-
49
- def register=(arg)
50
- @register = check_bool(arg)
51
- end
52
-
53
- def use
54
- default_template
55
- end
56
-
57
- private
58
-
59
- def blank?(expr)
60
- return true if expr.nil?
61
- case expr
62
- when 'String', String
63
- return true if expr == ''
64
- when 'Array', 'Hash', Array, Hash
65
- return true if expr.empty?
66
- else
67
- false
68
- end
69
- false
70
- end
71
-
72
- def check_bool(arg)
73
- return 1 if arg.class == TrueClass
74
- return 1 if arg.to_s =~ /^y|yes|true|on|1$/i
75
- 0
76
- end
77
-
78
- def check_integer(int)
79
- return int.to_i if int.class == String
80
- int
81
- end
82
-
83
- def check_state_option(arg, options, entry)
84
- if options.include?(arg)
85
- Chef::Log.debug("#{self.class} #{self} adding option #{arg} for entry #{entry}")
86
- else
87
- Chef::Log.fail("#{self.class} #{self} object error: Unknown option #{arg} for entry #{entry}")
88
- raise 'Unknown option'
89
- end
90
- end
91
-
92
- def check_state_options(arg, options, entry)
93
- if arg.class == String
94
- check_state_options(arg.split(','), options, entry)
95
- elsif arg.class == Array
96
- arg.each { |a| check_state_option(a.strip, options, entry) }.join(',')
97
- else
98
- arg
99
- end
100
- end
101
-
102
- def check_use_and_name(default)
103
- return nil if default.nil?
104
- return nil if to_s == default.to_s
105
- default
106
- end
107
-
108
- def default_template
109
- return @use unless @use.nil?
110
- return nil if @name
111
- case self
112
- when Nagios::Command
113
- check_use_and_name(Nagios.instance.default_command)
114
- when Nagios::Contactgroup
115
- check_use_and_name(Nagios.instance.default_contactgroup)
116
- when Nagios::Contact
117
- check_use_and_name(Nagios.instance.default_contact)
118
- when Nagios::Hostgroup
119
- check_use_and_name(Nagios.instance.default_hostgroup)
120
- when Nagios::Host
121
- check_use_and_name(Nagios.instance.default_host)
122
- when Nagios::Servicegroup
123
- check_use_and_name(Nagios.instance.default_servicegroup)
124
- when Nagios::Service
125
- check_use_and_name(Nagios.instance.default_service)
126
- when Nagios::Timeperiod
127
- check_use_and_name(Nagios.instance.default_timeperiod)
128
- end
129
- end
130
-
131
-
132
- def get_commands(obj)
133
- obj.map(&:to_s).join(',')
134
- end
135
-
136
- def configured_option(method, option)
137
- value = send(method)
138
- return nil if blank?(value)
139
- value = value.split(',') if value.is_a? String
140
- value = value.map do |e|
141
- (@not_modifiers[option][e] || '') + e
142
- end.join(',') if value.is_a? Array
143
- value
144
- end
145
-
146
- def configured_options
147
- configured = {}
148
- config_options.each do |m, o|
149
- next if o.nil?
150
- value = configured_option(m, o)
151
- next if value.nil?
152
- configured[o] = value
153
- end
154
- configured
155
- end
156
-
157
- def get_definition(options, group)
158
- return nil if to_s == '*'
159
- return nil if to_s == 'null'
160
- d = ["define #{group} {"]
161
- d += get_definition_options(options)
162
- d += ['}']
163
- d.join("\n")
164
- end
165
-
166
- def get_definition_options(options)
167
- r = []
168
- longest = get_longest_option(options)
169
- options.each do |k, v|
170
- k = k.to_s
171
- v = (@add_modifiers[k] || '') + v.to_s
172
- diff = longest - k.length
173
- r.push(k.rjust(k.length + 2) + v.rjust(v.length + diff + 2))
174
- end
175
- r
176
- end
177
-
178
- def get_longest_option(options)
179
- longest = 0
180
- options.each do |k, _|
181
- longest = k.length if longest < k.length
182
- end
183
- longest
184
- end
185
-
186
- def get_members(option, object)
187
- members = []
188
- case option
189
- when String
190
- members = object == Nagios::Command ? [option] : option.split(',')
191
- members.map(&:strip!)
192
- when Array
193
- members = option
194
- else
195
- Chef::Log.fail("Nagios fail: Use an Array or comma seperated String for option: #{option} within #{self.class}")
196
- raise 'Use an Array or comma seperated String for option'
197
- end
198
- members
199
- end
200
-
201
-
202
- def get_timeperiod(obj)
203
- return nil if obj.nil?
204
- return obj.to_s if obj.class == Nagios::Timeperiod
205
- obj
206
- end
207
-
208
- def merge_attributes(obj)
209
- config_options.each do |m, _|
210
- n = obj.send(m)
211
- next if n.nil?
212
- m += '='
213
- send(m, n) if respond_to?(m)
214
- end
215
- end
216
-
217
- def merge_members(obj)
218
- Chef::Log.debug("Nagios debug: The method merge_members is not supported by #{obj.class}")
219
- end
220
-
221
- def push(obj)
222
- Chef::Log.debug("Nagios debug: Cannot push #{obj} into #{self.class}")
223
- end
224
-
225
- def push_object(obj, hash)
226
- return if hash.key?('null')
227
- if obj.to_s == 'null'
228
- hash.clear
229
- hash[obj.to_s] = obj
230
- elsif hash[obj.to_s].nil?
231
- hash[obj.to_s] = obj
232
- else
233
- Chef::Log.debug("Nagios debug: #{self.class} already contains #{obj.class} with name: #{obj}")
234
- end
235
- end
236
-
237
- def pop_object(obj, hash)
238
- if hash.key?(obj.to_s)
239
- hash.delete(obj.to_s)
240
- else
241
- Chef::Log.debug("Nagios debug: #{self.class} does not contain #{obj.class} with name: #{obj}")
242
- end
243
- end
244
-
245
- def notification_commands(obj)
246
- commands = []
247
- case obj
248
- when Nagios::Command
249
- commands.push(obj)
250
- when Array
251
- obj.each { |o| commands += notification_commands(o) }
252
- when String
253
- obj.split(',').each do |o|
254
- c = Nagios::Command.new(o.strip)
255
- n = Nagios.instance.find(c)
256
- if c == n
257
- Chef::Log.fail("#{self.class} fail: Cannot find command #{o} please define it first.")
258
- raise "#{self.class} fail: Cannot find command #{o} please define it first."
259
- else
260
- commands.push(n)
261
- end
262
- end
263
- end
264
- commands
265
- end
266
-
267
-
268
- def hostname(name)
269
- if Nagios.instance.normalize_hostname
270
- name.downcase
271
- else
272
- name
273
- end
274
- end
275
-
276
- def update_options(hash)
277
- return nil if blank?(hash)
278
- update_hash_options(hash) if hash.respond_to?('each_pair')
279
- end
280
-
281
- def update_hash_options(hash)
282
- hash.each do |k, v|
283
- push(Nagios::CustomOption.new(k.upcase, v)) if k.start_with?('_')
284
- m = k + '='
285
- send(m, v) if respond_to?(m)
286
- end
287
- end
288
-
289
- def update_members(hash, option, object, remote = false)
290
- return if blank?(hash) || hash[option].nil?
291
- if hash[option].is_a?(String) && hash[option].start_with?('+')
292
- @add_modifiers[option] = '+'
293
- hash[option] = hash[option][1..-1]
294
- end
295
- get_members(hash[option], object).each do |member|
296
- if member.start_with?('!')
297
- member = member[1..-1]
298
- @not_modifiers[option][member] = '!'
299
- end
300
- n = Nagios.instance.find(object.new(member))
301
- push(n)
302
- n.push(self) if remote
303
- end
304
- end
305
-
306
-
307
- def update_dependency_members(hash, option, object)
308
- return if blank?(hash) || hash[option].nil?
309
- get_members(hash[option], object).each do |member|
310
- push_dependency(Nagios.instance.find(object.new(member)))
311
- end
312
- end
313
- end
314
- end