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,91 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name:: nagios
4
- # Library:: command
5
- #
6
- # Copyright 2014, Sander Botman
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
-
20
- require_relative 'base'
21
-
22
- class Nagios
23
- #
24
- # This class holds all methods with regard to command options,
25
- # that are used within nagios configurations.
26
- #
27
- class Command < Nagios::Base
28
- attr_reader :command_name,
29
- :timeout
30
- attr_accessor :command_line
31
-
32
- def initialize(command_name)
33
- cmd = command_name.split('!')
34
- @command_name = cmd.shift
35
- @timeout = nil
36
- super()
37
- end
38
-
39
- def definition
40
- if blank?(command_line)
41
- "# Skipping #{command_name} because command_line is missing."
42
- else
43
- get_definition(configured_options, 'command')
44
- end
45
- end
46
-
47
- def self.create(name)
48
- Nagios.instance.find(Nagios::Command.new(name))
49
- end
50
-
51
- def command_line=(command_line)
52
- param = command_timeout(command_line)
53
- @command_line = if @timeout.nil?
54
- command_line
55
- elsif param.nil?
56
- command_line + " -t #{@timeout}"
57
- else
58
- command_line.gsub(param, "-t #{@timeout}")
59
- end
60
- @command_line
61
- end
62
-
63
- def import(hash)
64
- @command_line = hash if hash.class == String
65
- hash['command_line'] == hash['command'] unless hash['command'].nil?
66
- update_options(hash)
67
- end
68
-
69
- def to_s
70
- command_name
71
- end
72
-
73
- private
74
-
75
- def command_timeout(command_line)
76
- if command_line =~ /(-t *?(\d+))/
77
- timeout = Regexp.last_match[2].to_i + 5
78
- @timeout = timeout if @timeout.nil? || timeout > @timeout
79
- return Regexp.last_match[1]
80
- end
81
- nil
82
- end
83
-
84
- def config_options
85
- {
86
- 'command_name' => 'command_name',
87
- 'command_line' => 'command_line',
88
- }
89
- end
90
- end
91
- end
@@ -1,230 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name:: nagios
4
- # Library:: contact
5
- #
6
- # Copyright 2014, Sander Botman
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
-
20
- require_relative 'base'
21
-
22
- class Nagios
23
- #
24
- # This class holds all methods with regard to contact options,
25
- # that are used within nagios configurations.
26
- #
27
- class Contact < Nagios::Base
28
- attr_reader :contact_name,
29
- :contactgroups,
30
- :custom_options
31
-
32
- attr_accessor :alias,
33
- :host_notifications_enabled,
34
- :service_notifications_enabled,
35
- :host_notification_period,
36
- :service_notification_period,
37
- :host_notification_options,
38
- :service_notification_options,
39
- :host_notification_commands,
40
- :service_notification_commands,
41
- :email,
42
- :pager,
43
- :addressx,
44
- :can_submit_commands,
45
- :retain_status_information,
46
- :retain_nonstatus_information
47
-
48
- def initialize(contact_name)
49
- @contact_name = contact_name
50
- @contactgroups = {}
51
- @host_notification_commands = []
52
- @service_notification_commands = []
53
- @custom_options = {}
54
- super()
55
- end
56
-
57
- def contactgroups_list
58
- @contactgroups.values.map(&:to_s).sort.join(',')
59
- end
60
-
61
- def definition
62
- if email.nil? && name.nil? && pager.nil?
63
- "# Skipping #{contact_name} because missing email/pager."
64
- else
65
- configured = configured_options
66
- custom_options.each { |_, v| configured[v.to_s] = v.value }
67
- get_definition(configured, 'contact')
68
- end
69
- end
70
-
71
- def self.create(name)
72
- Nagios.instance.find(Nagios::Contact.new(name))
73
- end
74
-
75
- def host_notification_commands
76
- get_commands(@host_notification_commands)
77
- end
78
-
79
- def host_notification_commands=(obj)
80
- @host_notification_commands = notification_commands(obj)
81
- end
82
-
83
- def host_notification_period
84
- get_timeperiod(@host_notification_period)
85
- end
86
-
87
- def import(hash)
88
- update_options(hash)
89
- update_members(hash, 'contactgroups', Nagios::Contactgroup, true)
90
- end
91
-
92
- def push(obj)
93
- case obj
94
- when Nagios::Contactgroup
95
- push_object(obj, @contactgroups)
96
- when Nagios::Timeperiod
97
- @host_notification_period = obj
98
- @service_notification_period = obj
99
- when Nagios::CustomOption
100
- push_object(obj, @custom_options)
101
- end
102
- end
103
-
104
- def pop(obj)
105
- return if obj == self
106
- case obj
107
- when Nagios::Contactgroup
108
- if @contactgroups.keys?(obj.to_s)
109
- pop_object(obj, @contactgroups)
110
- pop(self, obj)
111
- end
112
- when Nagios::Timeperiod
113
- @host_notification_period = nil if obj == @host_notification_period
114
- @service_notification_period = nil if obj == @service_notification_period
115
- when Nagios::CustomOption
116
- if @custom_options.keys?(obj.to_s)
117
- pop_object(obj, @custom_options)
118
- pop(self, obj)
119
- end
120
- end
121
- end
122
-
123
-
124
- def service_notification_commands
125
- get_commands(@service_notification_commands)
126
- end
127
-
128
- def service_notification_commands=(obj)
129
- @service_notification_commands = notification_commands(obj)
130
- end
131
-
132
- def service_notification_period
133
- get_timeperiod(@service_notification_period)
134
- end
135
-
136
- def to_s
137
- contact_name
138
- end
139
-
140
- # check the True/False options
141
- # default = nil
142
- def host_notifications_enabled=(arg)
143
- @host_notifications_enabled = check_bool(arg)
144
- end
145
-
146
- def service_notifications_enabled=(arg)
147
- @service_notifications_enabled = check_bool(arg)
148
- end
149
-
150
- def can_submit_commands=(arg)
151
- @can_submit_commands = check_bool(arg)
152
- end
153
-
154
- def retain_status_information=(arg)
155
- @retain_status_information = check_bool(arg)
156
- end
157
-
158
- def retain_nonstatus_information=(arg)
159
- @retain_nonstatus_information = check_bool(arg)
160
- end
161
-
162
- # check other options
163
- #
164
- # host_notification_options
165
- # This directive is used to define the host states for which notifications
166
- # can be sent out to this contact.
167
- # Valid options are a combination of one or more of the following:
168
- # d = notify on DOWN host states,
169
- # u = notify on UNREACHABLE host states,
170
- # r = notify on host recoveries (UP states),
171
- # f = notify when the host starts and stops flapping,
172
- # s = send notifications when host or service scheduled downtime starts and ends.
173
- #
174
- # If you specify n (none) as an option, the contact will not receive any type of
175
- # host notifications.
176
- def host_notification_options=(arg)
177
- @host_notification_options = check_state_options(
178
- arg, %w(d u r f s n), 'host_notification_options')
179
- end
180
-
181
- # service_notification_options
182
- # This directive is used to define the service states for which notifications
183
- # can be sent out to this contact.
184
- # Valid options are a combination of one or more of the following:
185
- # w = notify on WARNING service states,
186
- # u = notify on UNKNOWN service states,
187
- # c = notify on CRITICAL service states,
188
- # r = notify on service recoveries (OK states),
189
- # f = notify when the service starts and stops flapping.
190
- #
191
- # If you specify n (none) as an option, the contact will not receive any type of
192
- # service notifications.
193
- def service_notification_options=(arg)
194
- @service_notification_options = check_state_options(
195
- arg, %w(w u c r f n), 'service_notification_options')
196
- end
197
-
198
- private
199
-
200
- def config_options
201
- {
202
- 'name' => 'name',
203
- 'use' => 'use',
204
- 'contact_name' => 'contact_name',
205
- 'contactgroups_list' => 'contactgroups',
206
- 'alias' => 'alias',
207
- 'host_notifications_enabled' => 'host_notifications_enabled',
208
- 'service_notifications_enabled' => 'service_notifications_enabled',
209
- 'host_notification_period' => 'host_notification_period',
210
- 'service_notification_period' => 'service_notification_period',
211
- 'host_notification_options' => 'host_notification_options',
212
- 'service_notification_options' => 'service_notification_options',
213
- 'host_notification_commands' => 'host_notification_commands',
214
- 'service_notification_commands' => 'service_notification_commands',
215
- 'email' => 'email',
216
- 'pager' => 'pager',
217
- 'addressx' => 'addressx',
218
- 'can_submit_commands' => 'can_submit_commands',
219
- 'retain_status_information' => 'retain_status_information',
220
- 'retain_nonstatus_information' => 'retain_nonstatus_information',
221
- 'register' => 'register',
222
- }
223
- end
224
-
225
- def merge_members(obj)
226
- obj.contactgroups.each { |m| push(m) }
227
- obj.custom_options.each { |_, m| push(m) }
228
- end
229
- end
230
- end
@@ -1,112 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name:: nagios
4
- # Library:: contactgroup
5
- #
6
- # Copyright 2014, Sander Botman
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
-
20
- require_relative 'nagios'
21
-
22
- class Nagios
23
- #
24
- # This class holds all methods with regard to contactgroup options,
25
- # that are used within nagios configurations.
26
- #
27
- class Contactgroup < Nagios::Base
28
- attr_reader :contactgroup_name,
29
- :members,
30
- :contactgroup_members
31
-
32
- attr_accessor :alias
33
-
34
- def initialize(contactgroup_name)
35
- @contactgroup_name = contactgroup_name
36
- @members = {}
37
- @contactgroup_members = {}
38
- super()
39
- end
40
-
41
- def contactgroup_members_list
42
- @contactgroup_members.values.map(&:to_s).sort.join(',')
43
- end
44
-
45
- def self.create(name)
46
- Nagios.instance.find(Nagios::Contactgroup.new(name))
47
- end
48
-
49
- def definition
50
- get_definition(configured_options, 'contactgroup')
51
- end
52
-
53
- def import(hash)
54
- update_options(hash)
55
- update_members(hash, 'members', Nagios::Contact, true)
56
- update_members(hash, 'contactgroups_members', Nagios::Contactgroup, true)
57
- end
58
-
59
- def members_list
60
- @members.values.map(&:to_s).sort.join(',')
61
- end
62
-
63
- def push(obj)
64
- case obj
65
- when Nagios::Contact
66
- push_object(obj, @members)
67
- when Nagios::Contactgroup
68
- push_object(obj, @contactgroup_members)
69
- end
70
- end
71
-
72
- def pop(obj)
73
- return if obj == self
74
- case obj
75
- when Nagios::Contact
76
- if @members.keys?(obj.to_s)
77
- pop_object(obj, @members)
78
- pop(self, obj)
79
- end
80
- when Nagios::Contactgroup
81
- if @contactgroups_members.keys?(obj.to_s)
82
- pop_object(obj, @contactgroup_members)
83
- pop(self, obj)
84
- end
85
- end
86
- end
87
-
88
-
89
- def to_s
90
- contactgroup_name
91
- end
92
-
93
- private
94
-
95
- def config_options
96
- {
97
- 'name' => 'name',
98
- 'use' => 'use',
99
- 'contactgroup_name' => 'contactgroup_name',
100
- 'members_list' => 'members',
101
- 'contactgroup_members_list' => 'contactgroup_members',
102
- 'alias' => 'alias',
103
- 'register' => 'register',
104
- }
105
- end
106
-
107
- def merge_members(obj)
108
- obj.members.each { |m| push(m) }
109
- obj.contactgroup_members.each { |m| push(m) }
110
- end
111
- end
112
- end
@@ -1,36 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name:: nagios
4
- # Library:: custom_option
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
- class Nagios
21
- #
22
- # This class holds all methods with regard to custom_options
23
- #
24
- class CustomOption
25
- attr_reader :value
26
-
27
- def initialize(option, value)
28
- @option = option
29
- @value = value
30
- end
31
-
32
- def to_s
33
- @option
34
- end
35
- end
36
- end