cloud-mu 2.1.0beta → 3.0.0beta

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 (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,282 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name:: nagios
4
- # Library:: nagios
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
- #
22
- # This class holds all methods with regard to the nagios model.
23
- #
24
- class Nagios
25
- attr_reader :commands,
26
- :contactgroups,
27
- :contacts,
28
- :hostgroups,
29
- :hosts,
30
- :servicegroups,
31
- :services,
32
- :timeperiods,
33
- :hostdependencies,
34
- :hostescalations,
35
- :servicedependencies,
36
- :serviceescalations,
37
- :resources
38
-
39
- attr_accessor :host_name_attribute,
40
- :normalize_hostname,
41
- :default_command,
42
- :default_contactgroup,
43
- :default_contact,
44
- :default_hostgroup,
45
- :default_host,
46
- :default_servicegroup,
47
- :default_service,
48
- :default_timeperiod
49
-
50
- def initialize
51
- @commands = {}
52
- @contactgroups = {}
53
- @contacts = {}
54
- @hostgroups = {}
55
- @hosts = {}
56
- @servicegroups = {}
57
- @services = {}
58
- @timeperiods = {}
59
- @hostdependencies = {}
60
- @hostescalations = []
61
- @servicedependencies = {}
62
- @serviceescalations = []
63
- @resources = {}
64
- @host_name_attribute = 'hostname'
65
- @normalize_hostname = false
66
- end
67
-
68
-
69
- def commands
70
- Hash[@commands.sort]
71
- end
72
-
73
- def contactgroups
74
- Hash[@contactgroups.sort]
75
- end
76
-
77
- def contacts
78
- Hash[@contacts.sort]
79
- end
80
-
81
- def delete(hash, key)
82
- case hash
83
- when 'command'
84
- @commands.delete(key)
85
- when 'contactgroup'
86
- @contactgroups.delete(key)
87
- when 'contact'
88
- @contacts.delete(key)
89
- when 'hostgroup'
90
- @hostgroups.delete(key)
91
- when 'host'
92
- @hosts.delete(key)
93
- when 'servicegroup'
94
- @servicegroups.delete(key)
95
- when 'service'
96
- @services.delete(key)
97
- when 'timeperiod'
98
- @timeperiods.delete(key)
99
- when 'hostdependency'
100
- @hostdependencies.delete(key)
101
- when 'hostescalation'
102
- @hostescalations.delete(key)
103
- when 'servicedependency'
104
- @servicedependencies.delete(key)
105
- when 'serviceescalation'
106
- @serviceescalations.delete(key)
107
- when 'resource'
108
- @resources.delete(key)
109
- end
110
- end
111
-
112
-
113
- def find(obj)
114
- case obj
115
- when Nagios::Command
116
- find_object(obj, @commands)
117
- when Nagios::Contact
118
- find_object(obj, @contacts)
119
- when Nagios::Contactgroup
120
- find_object(obj, @contactgroups)
121
- when Nagios::Host
122
- find_object(obj, @hosts)
123
- when Nagios::Hostgroup
124
- find_object(obj, @hostgroups)
125
- when Nagios::Service
126
- find_object(obj, @services)
127
- when Nagios::Servicegroup
128
- find_object(obj, @servicegroups)
129
- when Nagios::Timeperiod
130
- find_object(obj, @timeperiods)
131
- when Nagios::Hostdependency
132
- find_object(obj, @hostdependencies)
133
- when Nagios::Servicedependency
134
- find_object(obj, @servicedependencies)
135
- when Nagios::Resource
136
- find_object(obj, @resources)
137
- end
138
- end
139
-
140
-
141
- def hosts
142
- Hash[@hosts.sort]
143
- end
144
-
145
- def hostdependencies
146
- Hash[@hostdependencies.sort]
147
- end
148
-
149
- def hostgroups
150
- Hash[@hostgroups.sort]
151
- end
152
-
153
- def normalize_hostname=(expr)
154
- @normalize_hostname = (expr == true || !(expr =~ /y|yes|true|1/).nil?)
155
- end
156
-
157
- def push(obj)
158
- case obj
159
- when Chef::Node
160
- push_node(obj)
161
- when Nagios::Command
162
- push_object(obj)
163
- when Nagios::Contact
164
- push_object(obj)
165
- when Nagios::Contactgroup
166
- push_object(obj)
167
- when Nagios::Host
168
- push_object(obj)
169
- when Nagios::Hostgroup
170
- push_object(obj)
171
- when Nagios::Service
172
- push_object(obj)
173
- when Nagios::Servicegroup
174
- push_object(obj)
175
- when Nagios::Timeperiod
176
- push_object(obj)
177
- when Nagios::Hostdependency
178
- push_object(obj)
179
- when Nagios::Hostescalation
180
- @hostescalations.push(obj)
181
- when Nagios::Servicedependency
182
- push_object(obj)
183
- when Nagios::Serviceescalation
184
- @serviceescalations.push(obj)
185
- when Nagios::Resource
186
- push_object(obj)
187
- else
188
- Chef::Log.fail("Nagios error: Pushing unknown object: #{obj.class} into Nagios.instance")
189
- raise
190
- end
191
- end
192
-
193
-
194
- def timeperiods
195
- Hash[@timeperiods.sort]
196
- end
197
-
198
- def resources
199
- Hash[@resources.sort]
200
- end
201
-
202
- def self.instance
203
- @instance ||= Nagios.new
204
- end
205
-
206
- def services
207
- Hash[@services.sort]
208
- end
209
-
210
- def servicedependencies
211
- Hash[@servicedependencies.sort]
212
- end
213
-
214
- def servicegroups
215
- Hash[@servicegroups.sort]
216
- end
217
-
218
- private
219
-
220
- def blank?(expr)
221
- return true if expr.nil?
222
- case expr
223
- when 'String', String
224
- return true if expr == ''
225
- when 'Array', 'Hash', Array, Hash
226
- return true if expr.empty?
227
- else
228
- return false
229
- end
230
- false
231
- end
232
-
233
- def find_object(obj, hash)
234
- current = hash[obj.to_s]
235
- if current.nil?
236
- Chef::Log.debug("Nagios debug: Creating entry for #{obj.class} with name: #{obj}")
237
- hash[obj.to_s] = obj
238
- obj
239
- else
240
- Chef::Log.debug("Nagios debug: Found entry for #{obj.class} with name: #{obj}")
241
- current
242
- end
243
- end
244
-
245
- def get_groups(obj)
246
- groups = obj['roles'].nil? ? [] : obj['roles'].dup
247
- groups += [obj['os']] unless blank?(obj['os'])
248
- groups + [obj.chef_environment]
249
- end
250
-
251
- def get_hostname(obj)
252
- return obj.name if @host_name_attribute == 'name'
253
- return obj['nagios']['host_name'] unless blank?(obj['nagios']) || blank?(obj['nagios']['host_name'])
254
- return obj[@host_name_attribute] unless blank?(obj[@host_name_attribute])
255
- return obj['hostname'] unless blank?(obj['hostname'])
256
- return obj.name unless blank?(obj.name)
257
- nil
258
- end
259
-
260
- def push_node(obj)
261
- groups = get_groups(obj)
262
- hostname = get_hostname(obj)
263
- return nil if hostname.nil?
264
-
265
- host = find(Nagios::Host.new(hostname))
266
- # TODO: merge the ip_to_monitor funtion into this logic here
267
- host.address = obj['ipaddress']
268
- host.import(obj['nagios']) unless obj['nagios'].nil?
269
-
270
- groups.each do |r|
271
- hg = find(Nagios::Hostgroup.new(r))
272
- hg.push(host)
273
- host.push(hg)
274
- end
275
- end
276
-
277
-
278
- def push_object(obj)
279
- object = find(obj.class.new(obj.to_s))
280
- object.merge!(obj)
281
- end
282
- end
@@ -1,59 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name:: nagios
4
- # Library:: 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
- require_relative 'base'
21
-
22
- class Nagios
23
- #
24
- # This class holds all methods with regard to resource options,
25
- # that are used within nagios configurations.
26
- #
27
- class Resource < Nagios::Base
28
- attr_reader :key
29
- attr_accessor :value
30
-
31
- def initialize(key, value = nil)
32
- @key = key
33
- @value = value
34
- super()
35
- end
36
-
37
- def definition
38
- if blank?(value)
39
- "# Skipping #{key} because the value is missing."
40
- elsif key =~ /^USER([1-9]|[1-9][0-9]|[1-2][0-4][0-9]|25[0-6])$/
41
- "$#{@key}$=#{@value}"
42
- else
43
- "# Skipping #{key} because the it's not valid. Use USER[1-256] as your key."
44
- end
45
- end
46
-
47
- def self.create(name)
48
- Nagios.instance.find(Nagios::Resource.new(name))
49
- end
50
-
51
- def import(hash)
52
- update_options(hash)
53
- end
54
-
55
- def to_s
56
- key
57
- end
58
- end
59
- end
@@ -1,455 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name:: nagios
4
- # Library:: service
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
- require_relative 'base'
22
-
23
- class Nagios
24
- #
25
- # This class holds all methods with regard to servicedependency options,
26
- # that are used within nagios configurations.
27
- #
28
- class Service < Nagios::Base
29
- attr_reader :service_description,
30
- :host_name,
31
- :hostgroup_name,
32
- :contacts,
33
- :contact_groups,
34
- :check_command,
35
- :servicegroups,
36
- :hostgroups,
37
- :custom_options
38
-
39
- attr_accessor :display_name,
40
- :is_volatile,
41
- :initial_state,
42
- :max_check_attempts,
43
- :check_interval,
44
- :retry_interval,
45
- :active_checks_enabled,
46
- :passive_checks_enabled,
47
- :check_period,
48
- :obsess_over_service,
49
- :check_freshness,
50
- :freshness_threshold,
51
- :event_handler,
52
- :event_handler_enabled,
53
- :low_flap_threshold,
54
- :high_flap_threshold,
55
- :flap_detection_enabled,
56
- :flap_detection_options,
57
- :process_perf_data,
58
- :retain_status_information,
59
- :retain_nonstatus_information,
60
- :notification_interval,
61
- :first_notification_delay,
62
- :notification_period,
63
- :notification_options,
64
- :notifications_enabled,
65
- :parallelize_check,
66
- :stalking_options,
67
- :notes,
68
- :notes_url,
69
- :action_url,
70
- :icon_image,
71
- :icon_image_alt
72
-
73
- def initialize(service_description)
74
- @service_description = service_description
75
- srv = service_description.split('!')
76
- @check_command = srv.shift
77
- @arguments = srv
78
- @servicegroups = {}
79
- @contacts = {}
80
- @contact_groups = {}
81
- @hostgroups = {}
82
- @hosts = {}
83
- @custom_options = {}
84
- super()
85
- end
86
-
87
-
88
- def check_command
89
- if blank?(@arguments)
90
- @check_command.to_s
91
- else
92
- @check_command.to_s + '!' + @arguments.join('!')
93
- end
94
- end
95
-
96
- def check_command=(cmd)
97
- cmd = cmd.split('!')
98
- cmd.shift
99
- @arguments = cmd
100
- end
101
-
102
- def check_period
103
- get_timeperiod(@check_period)
104
- end
105
-
106
- # contacts
107
- # This is a list of the short names of the contacts that should be notified
108
- # whenever there are problems (or recoveries) with this host.
109
- # Multiple contacts should be separated by commas.
110
- # Useful if you want notifications to go to just a few people and don't want
111
- # to configure contact groups.
112
- # You must specify at least one contact or contact group in each host definition.
113
- def contacts_list
114
- @contacts.values.map(&:to_s).sort.join(',')
115
- end
116
-
117
- # contact_groups
118
- # This is a list of the short names of the contact groups that should be notified
119
- # whenever there are problems (or recoveries) with this host.
120
- # Multiple contact groups should be separated by commas.
121
- # You must specify at least one contact or contact group in each host definition.
122
- def contact_groups_list
123
- @contact_groups.values.map(&:to_s).sort.join(',')
124
- end
125
-
126
- def definition
127
- if blank?(hostgroup_name_list) && blank?(host_name_list) && name.nil?
128
- "# Skipping #{service_description} because host_name and hostgroup_name are missing."
129
- else
130
- configured = configured_options
131
- custom_options.each { |_, v| configured[v.to_s] = v.value }
132
- get_definition(configured, 'service')
133
- end
134
- end
135
-
136
- # host_name
137
- # This directive is used to return all host objects
138
- def host_name
139
- @hosts
140
- end
141
-
142
- # host_name_list
143
- # This directive is used to specify the short name(s) of the host(s) that the service
144
- # "runs" on or is associated with. Multiple hosts should be separated by commas.
145
- def host_name_list
146
- @hosts.values.map(&:to_s).sort.join(',')
147
- end
148
-
149
- # hostgroup_name
150
- # This directive is used to return all hostgroup objects
151
- def hostgroup_name
152
- @hostgroups
153
- end
154
-
155
- # hostgroup_name_list
156
- # This directive is used to specify the short name(s) of the hostgroup(s) that the
157
- # service "runs" on or is associated with. Multiple hostgroups should be separated by commas.
158
- # The hostgroup_name may be used instead of, or in addition to, the host_name directive.
159
- def hostgroup_name_list
160
- @hostgroups.values.map(&:to_s).sort.join(',')
161
- end
162
-
163
- def import(hash)
164
- update_options(hash)
165
- update_members(hash, 'contacts', Nagios::Contact)
166
- update_members(hash, 'contact_groups', Nagios::Contactgroup)
167
- update_members(hash, 'host_name', Nagios::Host)
168
- update_members(hash, 'hostgroup_name', Nagios::Hostgroup)
169
- update_members(hash, 'servicegroups', Nagios::Servicegroup, true)
170
- update_members(hash, 'check_command', Nagios::Command)
171
- end
172
-
173
- def notification_period
174
- get_timeperiod(@notification_period)
175
- end
176
-
177
- def push(obj)
178
- case obj
179
- when Nagios::Servicegroup
180
- push_object(obj, @servicegroups)
181
- when Nagios::Hostgroup
182
- push_object(obj, @hostgroups)
183
- when Nagios::Host
184
- push_object(obj, @hosts)
185
- when Nagios::Contact
186
- push_object(obj, @contacts)
187
- when Nagios::Contactgroup
188
- push_object(obj, @contact_groups)
189
- when Nagios::Command
190
- @check_command = obj
191
- when Nagios::Timeperiod
192
- @check_period = obj
193
- @notification_period = obj
194
- when Nagios::CustomOption
195
- push_object(obj, @custom_options)
196
- end
197
- end
198
-
199
- def pop(obj)
200
- return if obj == self
201
- case obj
202
- when Nagios::Servicegroup
203
- if @servicegroups.keys?(obj.to_s)
204
- pop_object(obj, @servicegroups)
205
- pop(self, obj)
206
- end
207
- when Nagios::Hostgroup
208
- if @hostgroups.keys?(obj.to_s)
209
- pop_object(obj, @hostgroups)
210
- pop(self, obj)
211
- end
212
- when Nagios::Host
213
- if @hosts.keys?(obj.to_s)
214
- pop_object(obj, @hosts)
215
- pop(self, obj)
216
- end
217
- when Nagios::Contact
218
- if @contacts.keys?(obj.to_s)
219
- pop_object(obj, @contacts)
220
- pop(self, obj)
221
- end
222
- when Nagios::Contactgroup
223
- if @contact_groups.keys?(obj.to_s)
224
- pop_object(obj, @contact_groups)
225
- pop(self, obj)
226
- end
227
- when Nagios::Command
228
- @check_command = nil if @check_command == obj
229
- when Nagios::Timeperiod
230
- @check_period = nil if @check_command == obj
231
- @notification_period = nil if @check_command == obj
232
- when Nagios::CustomOption
233
- if @custom_options.keys?(obj.to_s)
234
- pop_object(obj, @custom_options)
235
- pop(self, obj)
236
- end
237
- end
238
- end
239
-
240
-
241
- # servicegroups
242
- # This directive is used to define the description of the service, which may contain spaces,
243
- # dashes, and colons (semicolons, apostrophes, and quotation marks should be avoided).
244
- # No two services associated with the same host can have the same description.
245
- # Services are uniquely identified with their host_name and service_description directives.
246
- def servicegroups_list
247
- @servicegroups.values.map(&:to_s).sort.join(',')
248
- end
249
-
250
- def self.create(name)
251
- Nagios.instance.find(Nagios::Service.new(name))
252
- end
253
-
254
- def to_s
255
- service_description
256
- end
257
-
258
- # check the integer options
259
- # default = nil
260
-
261
- def max_check_attempts=(int)
262
- @max_check_attempts = check_integer(int)
263
- end
264
-
265
- def check_interval=(int)
266
- @check_interval = check_integer(int)
267
- end
268
-
269
- def retry_interval=(int)
270
- @retry_interval = check_integer(int)
271
- end
272
-
273
- def freshness_threshold=(int)
274
- @freshness_threshold = check_integer(int)
275
- end
276
-
277
- def low_flap_threshold=(int)
278
- @low_flap_threshold = check_integer(int)
279
- end
280
-
281
- def high_flap_threshold=(int)
282
- @high_flap_threshold = check_integer(int)
283
- end
284
-
285
- def notification_interval=(int)
286
- @notification_interval = check_integer(int)
287
- end
288
-
289
- def first_notification_delay=(int)
290
- @first_notification_delay = check_integer(int)
291
- end
292
-
293
- # check the True/False options
294
- # default = nil
295
-
296
- # rubocop:disable Style/PredicateName
297
- def is_volatile=(arg)
298
- @is_volatile = check_bool(arg)
299
- end
300
- # rubocop:enable Style/PredicateName
301
-
302
- def active_checks_enabled=(arg)
303
- @active_checks_enabled = check_bool(arg)
304
- end
305
-
306
- def passive_checks_enabled=(arg)
307
- @passive_checks_enabled = check_bool(arg)
308
- end
309
-
310
- def obsess_over_service=(arg)
311
- @obsess_over_service = check_bool(arg)
312
- end
313
-
314
- def check_freshness=(arg)
315
- @check_freshness = check_bool(arg)
316
- end
317
-
318
- def event_handler_enabled=(arg)
319
- @event_handler_enabled = check_bool(arg)
320
- end
321
-
322
- def flap_detection_enabled=(arg)
323
- @flap_detection_enabled = check_bool(arg)
324
- end
325
-
326
- def process_perf_data=(arg)
327
- @process_perf_data = check_bool(arg)
328
- end
329
-
330
- def retain_status_information=(arg)
331
- @retain_status_information = check_bool(arg)
332
- end
333
-
334
- def retain_nonstatus_information=(arg)
335
- @retain_nonstatus_information = check_bool(arg)
336
- end
337
-
338
- def notifications_enabled=(arg)
339
- @notifications_enabled = check_bool(arg)
340
- end
341
-
342
- def parallelize_check=(arg)
343
- @parallelize_check = check_bool(arg)
344
- end
345
-
346
- # check other options
347
-
348
- # flap_detection_options
349
- # This directive is used to determine what service states the flap detection logic will use for this service.
350
- # Valid options are a combination of one or more of the following:
351
- # o = OK states,
352
- # w = WARNING states,
353
- # c = CRITICAL states,
354
- # u = UNKNOWN states.
355
-
356
- def flap_detection_options=(arg)
357
- @flap_detection_options = check_state_options(arg, %w(o w u c), 'flap_detection_options')
358
- end
359
-
360
- # notification_options
361
- # This directive is used to determine when notifications for the service should be sent out.
362
- # Valid options are a combination of one or more of the following:
363
- # w = send notifications on a WARNING state,
364
- # u = send notifications on an UNKNOWN state,
365
- # c = send notifications on a CRITICAL state,
366
- # r = send notifications on recoveries (OK state),
367
- # f = send notifications when the service starts and stops flapping,
368
- # s = send notifications when scheduled downtime starts and ends.
369
- #
370
- # If you specify n (none) as an option, no service notifications will be sent out.
371
- # If you do not specify any notification options, Nagios will assume that you want
372
- # notifications to be sent out for all possible states.
373
- #
374
- # Example: If you specify w,r in this field, notifications will only be sent out when
375
- # the service goes into a WARNING state and when it recovers from a WARNING state.
376
-
377
- def notification_options=(arg)
378
- @notification_options = check_state_options(arg, %w(w u c r f s n), 'notification_options')
379
- end
380
-
381
- # stalking_options
382
- # This directive determines which service states "stalking" is enabled for.
383
- # Valid options are a combination of one or more of the following:
384
- # o = stalk on OK states,
385
- # w = stalk on WARNING states,
386
- # u = stalk on UNKNOWN states,
387
- # c = stalk on CRITICAL states.
388
- #
389
- # More information on state stalking can be found here.
390
-
391
- def stalking_options=(arg)
392
- @stalking_options = check_state_options(arg, %w(o w u c), 'stalking_options')
393
- end
394
-
395
- private
396
-
397
- def config_options
398
- {
399
- 'name' => 'name',
400
- 'use' => 'use',
401
- 'service_description' => 'service_description',
402
- 'host_name_list' => 'host_name',
403
- 'hostgroup_name_list' => 'hostgroup_name',
404
- 'servicegroups_list' => 'servicegroups',
405
- 'display_name' => 'display_name',
406
- 'is_volatile' => 'is_volatile',
407
- 'check_command' => 'check_command',
408
- 'initial_state' => 'initial_state',
409
- 'max_check_attempts' => 'max_check_attempts',
410
- 'check_interval' => 'check_interval',
411
- 'retry_interval' => 'retry_interval',
412
- 'active_checks_enabled' => 'active_checks_enabled',
413
- 'passive_checks_enabled' => 'passive_checks_enabled',
414
- 'check_period' => 'check_period',
415
- 'obsess_over_service' => 'obsess_over_service',
416
- 'check_freshness' => 'check_freshness',
417
- 'freshness_threshold' => 'freshness_threshold',
418
- 'event_handler' => 'event_handler',
419
- 'event_handler_enabled' => 'event_handler_enabled',
420
- 'low_flap_threshold' => 'low_flap_threshold',
421
- 'high_flap_threshold' => 'high_flap_threshold',
422
- 'flap_detection_enabled' => 'flap_detection_enabled',
423
- 'flap_detection_options' => 'flap_detection_options',
424
- 'process_perf_data' => 'process_perf_data',
425
- 'retain_status_information' => 'retain_status_information',
426
- 'retain_nonstatus_information' => 'retain_nonstatus_information',
427
- 'notification_interval' => 'notification_interval',
428
- 'first_notification_delay' => 'first_notification_delay',
429
- 'notification_period' => 'notification_period',
430
- 'notification_options' => 'notification_options',
431
- 'notifications_enabled' => 'notifications_enabled',
432
- 'parallelize_check' => 'parallelize_check',
433
- 'contacts_list' => 'contacts',
434
- 'contact_groups_list' => 'contact_groups',
435
- 'stalking_options' => 'stalking_options',
436
- 'notes' => 'notes',
437
- 'notes_url' => 'notes_url',
438
- 'action_url' => 'action_url',
439
- 'icon_image' => 'icon_image',
440
- 'icon_image_alt' => 'icon_image_alt',
441
- 'register' => 'register',
442
- }
443
- end
444
-
445
-
446
- def merge_members(obj)
447
- obj.contacts.each { |m| push(m) }
448
- obj.host_name.each { |m| push(m) }
449
- obj.servicegroups.each { |m| push(m) }
450
- obj.hostgroup_name.each { |m| push(m) }
451
- obj.contact_groups.each { |m| push(m) }
452
- obj.custom_options.each { |_, m| push(m) }
453
- end
454
- end
455
- end