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,23 +0,0 @@
1
- require 'chef/search/query'
2
-
3
- # simplified access to databags in the nagios cookbook
4
- class NagiosDataBags
5
- attr_accessor :bag_list
6
-
7
- def initialize(bag_list = Chef::DataBag.list)
8
- @bag_list = bag_list
9
- end
10
-
11
- # Returns an array of data bag items or an empty array
12
- # Avoids unecessary calls to search by checking against
13
- # the list of known data bags.
14
- def get(bag_name)
15
- results = []
16
- if @bag_list.include?(bag_name)
17
- Chef::Search::Query.new.search(bag_name.to_s, '*:*') { |rows| results << rows }
18
- else
19
- Chef::Log.info "The #{bag_name} data bag does not exist."
20
- end
21
- results
22
- end
23
- end
@@ -1,90 +0,0 @@
1
- #
2
- # Author:: Joshua Sierles <joshua@37signals.com>
3
- # Author:: Tim Smith <tsmith@chef.io>
4
- # Cookbook Name:: nagios
5
- # Library:: default
6
- #
7
- # Copyright 2009, 37signals
8
- #
9
- # Licensed under the Apache License, Version 2.0 (the "License");
10
- # you may not use this file except in compliance with the License.
11
- # You may obtain a copy of the License at
12
- #
13
- # http://www.apache.org/licenses/LICENSE-2.0
14
- #
15
- # Unless required by applicable law or agreed to in writing, software
16
- # distributed under the License is distributed on an "AS IS" BASIS,
17
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- # See the License for the specific language governing permissions and
19
- # limitations under the License.
20
- #
21
- def nagios_boolean(true_or_false)
22
- true_or_false ? '1' : '0'
23
- end
24
-
25
- def nagios_interval(seconds)
26
- if seconds.to_i == 0
27
- raise ArgumentError, 'Specified nagios interval of 0 seconds is not allowed'
28
- end
29
- interval = seconds
30
- if node['nagios']['conf']['interval_length'].to_i != 1
31
- interval = seconds.to_f / node['nagios']['conf']['interval_length']
32
- end
33
- interval
34
- end
35
-
36
- def nagios_array(exp)
37
- return [] if exp.nil?
38
- case exp
39
- when String
40
- [exp]
41
- else
42
- exp
43
- end
44
- end
45
-
46
- def nagios_action_delete?(action)
47
- if action.is_a?(Symbol)
48
- return true if action == :delete || action == :remove
49
- elsif action.is_a?(Array)
50
- return true if action.include?(:delete) || action.include?(:remove)
51
- else
52
- false
53
- end
54
- end
55
-
56
- def nagios_action_create?(action)
57
- if action.is_a?(Symbol)
58
- return true if action == :create || action == :add
59
- elsif action.is_a?(Array)
60
- return true if action.include?(:create) || action.include?(:add)
61
- else
62
- false
63
- end
64
- end
65
-
66
- def nagios_attr(name)
67
- node['nagios'][name]
68
- end
69
-
70
- # decide whether to use internal or external IP addresses for this node
71
- # if the nagios server is not in the cloud, always use public IP addresses for cloud nodes.
72
- # if the nagios server is in the cloud, use private IP addresses for any
73
- # cloud servers in the same cloud, public IPs for servers in other clouds
74
- # (where other is defined by node['cloud']['provider'])
75
- # if the cloud IP is nil then use the standard IP address attribute. This is a work around
76
- # for OHAI incorrectly identifying systems on Cisco hardware as being in Rackspace
77
- def ip_to_monitor(monitored_host, server_host = node)
78
- # if interface to monitor is specified implicitly use that
79
- if node['nagios']['monitoring_interface'] && node['network']["ipaddress_#{node['nagios']['monitoring_interface']}"]
80
- node['network']["ipaddress_#{node['nagios']['monitoring_interface']}"]
81
- # if server is not in the cloud and the monitored host is
82
- elsif server_host['cloud'].nil? && monitored_host['cloud']
83
- monitored_host['cloud']['public_ipv4'].include?('.') ? monitored_host['cloud']['public_ipv4'] : monitored_host['ipaddress']
84
- # if server host is in the cloud and the monitored node is as well, but they are not on the same provider
85
- elsif server_host['cloud'] && monitored_host['cloud'] && monitored_host['cloud']['provider'] != server_host['cloud']['provider']
86
- monitored_host['cloud']['public_ipv4'].include?('.') ? monitored_host['cloud']['public_ipv4'] : monitored_host['ipaddress']
87
- else
88
- monitored_host['ipaddress']
89
- end
90
- end
@@ -1,412 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name:: nagios
4
- # Library:: host
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 host options,
26
- # that are used within nagios configurations.
27
- #
28
- class Host < Nagios::Base
29
- attr_reader :host_name,
30
- :parents,
31
- :hostgroups,
32
- :contacts,
33
- :contact_groups,
34
- :custom_options
35
-
36
- attr_accessor :alias,
37
- :display_name,
38
- :address,
39
- :check_command,
40
- :initial_state,
41
- :max_check_attempts,
42
- :check_interval,
43
- :retry_interval,
44
- :active_checks_enabled,
45
- :passive_checks_enabled,
46
- :check_period,
47
- :obsess_over_host,
48
- :check_freshness,
49
- :freshness_threshold,
50
- :event_handler,
51
- :event_handler_enabled,
52
- :low_flap_threshold,
53
- :high_flap_threshold,
54
- :flap_detection_enabled,
55
- :flap_detection_options,
56
- :process_perf_data,
57
- :retain_status_information,
58
- :retain_nonstatus_information,
59
- :notification_interval,
60
- :first_notification_delay,
61
- :notification_period,
62
- :notification_options,
63
- :notifications_enabled,
64
- :stalking_options,
65
- :notes,
66
- :notes_url,
67
- :action_url,
68
- :icon_image,
69
- :icon_image_alt,
70
- :vrml_image,
71
- :statusmap_image,
72
- :_2d_coords,
73
- :_3d_coords
74
-
75
- def initialize(host_name)
76
- @host_name = hostname(host_name)
77
- @hostgroups = {}
78
- @parents = {}
79
- @contacts = {}
80
- @contact_groups = {}
81
- @check_period = nil
82
- @notification_period = nil
83
- @custom_options = {}
84
- super()
85
- end
86
-
87
- def check_period
88
- get_timeperiod(@check_period)
89
- end
90
-
91
- # contacts
92
- # This is a list of the short names of the contacts that should be notified
93
- # whenever there are problems (or recoveries) with this host.
94
- # Multiple contacts should be separated by commas.
95
- # Useful if you want notifications to go to just a few people and don't want
96
- # to configure contact groups.
97
- # You must specify at least one contact or contact group in each host definition.
98
- def contacts_list
99
- @contacts.values.map(&:to_s).sort.join(',')
100
- end
101
-
102
- # contact_groups
103
- # This is a list of the short names of the contact groups that should be notified
104
- # whenever there are problems (or recoveries) with this host.
105
- # Multiple contact groups should be separated by commas.
106
- # You must specify at least one contact or contact group in each host definition.
107
- def contact_groups_list
108
- @contact_groups.values.map(&:to_s).sort.join(',')
109
- end
110
-
111
- def definition
112
- configured = configured_options
113
- custom_options.each { |_, v| configured[v.to_s] = v.value }
114
- get_definition(configured, 'host')
115
- end
116
-
117
- # hostgroups
118
- # This directive is used to identify the short name(s) of the hostgroup(s)
119
- # that the host belongs to. Multiple hostgroups should be separated by commas.
120
- # This directive may be used as an alternative to (or in addition to)
121
- # using the members directive in hostgroup definitions.
122
- def hostgroups_list
123
- @hostgroups.values.map(&:to_s).sort.join(',')
124
- end
125
-
126
- def import(hash)
127
- update_options(hash)
128
- update_members(hash, 'parents', Nagios::Host)
129
- update_members(hash, 'contacts', Nagios::Contact)
130
- update_members(hash, 'contact_groups', Nagios::Contactgroup)
131
- update_members(hash, 'hostgroups', Nagios::Hostgroup, true)
132
- end
133
-
134
- def notification_period
135
- get_timeperiod(@notification_period)
136
- end
137
-
138
- def notifications
139
- @notifications_enabled
140
- end
141
-
142
- def notifications=(arg)
143
- @notifications_enabled = check_bool(arg)
144
- end
145
-
146
- # parents
147
- # This directive is used to define a comma-delimited list of short names of
148
- # the "parent" hosts for this particular host. Parent hosts are typically routers,
149
- # switches, firewalls, etc. that lie between the monitoring host and a remote hosts.
150
- # A router, switch, etc. which is closest to the remote host is considered
151
- # to be that host's "parent".
152
- # If this host is on the same network segment as the host doing the monitoring
153
- # (without any intermediate routers, etc.) the host is considered to be on the local
154
- # network and will not have a parent host.
155
- def parents_list
156
- @parents.values.map(&:to_s).sort.join(',')
157
- end
158
-
159
- def push(obj)
160
- case obj
161
- when Nagios::Hostgroup
162
- push_object(obj, @hostgroups)
163
- when Nagios::Host
164
- push_object(obj, @parents)
165
- when Nagios::Contact
166
- push_object(obj, @contacts)
167
- when Nagios::Contactgroup
168
- push_object(obj, @contact_groups)
169
- when Nagios::Timeperiod
170
- @check_period = obj
171
- @notification_period = obj
172
- when Nagios::CustomOption
173
- push_object(obj, @custom_options)
174
- end
175
- end
176
-
177
- def pop(obj)
178
- return if obj == self
179
- case obj
180
- when Nagios::Hostgroup
181
- if @hostgroups.key?(obj.to_s)
182
- pop_object(obj, @hostgroups)
183
- obj.pop(self)
184
- end
185
- when Nagios::Host
186
- if @parents.key?(obj.to_s)
187
- pop_object(obj, @parents)
188
- obj.pop(self)
189
- end
190
- when Nagios::Contact
191
- if @contacts.keys?(obj.to_s)
192
- pop_object(obj, @contacts)
193
- obj.pop(self)
194
- end
195
- when Nagios::Contactgroup
196
- if @contact_groups.keys?(obj.to_s)
197
- pop_object(obj, @contact_groups)
198
- obj.pop(self)
199
- end
200
- when Nagios::Timeperiod
201
- @check_period = nil if @check_period == obj
202
- @notification_period = nil if @notification_period == obj
203
- when Nagios::CustomOption
204
- if @custom_options.keys?(obj.to_s)
205
- pop_object(obj, @custom_options)
206
- obj.pop(self)
207
- end
208
- end
209
- end
210
-
211
-
212
- def self.create(name)
213
- Nagios.instance.find(Nagios::Host.new(name))
214
- end
215
-
216
- def to_s
217
- host_name
218
- end
219
-
220
- # check the integer options
221
- # default = nil
222
-
223
- def max_check_attempts=(int)
224
- @max_check_attempts = check_integer(int)
225
- end
226
-
227
- def check_interval=(int)
228
- @check_interval = check_integer(int)
229
- end
230
-
231
- def retry_interval=(int)
232
- @retry_interval = check_integer(int)
233
- end
234
-
235
- def freshness_threshold=(int)
236
- @freshness_threshold = check_integer(int)
237
- end
238
-
239
- def low_flap_threshold=(int)
240
- @low_flap_threshold = check_integer(int)
241
- end
242
-
243
- def high_flap_threshold=(int)
244
- @high_flap_threshold = check_integer(int)
245
- end
246
-
247
- def notification_interval=(int)
248
- @notification_interval = check_integer(int)
249
- end
250
-
251
- def first_notification_delay=(int)
252
- @first_notification_delay = check_integer(int)
253
- end
254
-
255
- # check the True/False options
256
- # default = nil
257
-
258
- def active_checks_enabled=(arg)
259
- @active_checks_enabled = check_bool(arg)
260
- end
261
-
262
- def passive_checks_enabled=(arg)
263
- @passive_checks_enabled = check_bool(arg)
264
- end
265
-
266
- def obsess_over_host=(arg)
267
- @obsess_over_host = check_bool(arg)
268
- end
269
-
270
- def check_freshness=(arg)
271
- @check_freshness = check_bool(arg)
272
- end
273
-
274
- def event_handler_enabled=(arg)
275
- @event_handler_enabled = check_bool(arg)
276
- end
277
-
278
- def flap_detection_enabled=(arg)
279
- @flap_detection_enabled = check_bool(arg)
280
- end
281
-
282
- def process_perf_data=(arg)
283
- @process_perf_data = check_bool(arg)
284
- end
285
-
286
- def retain_status_information=(arg)
287
- @retain_status_information = check_bool(arg)
288
- end
289
-
290
- def retain_nonstatus_information=(arg)
291
- @retain_nonstatus_information = check_bool(arg)
292
- end
293
-
294
- def notifications_enabled=(arg)
295
- @notifications_enabled = check_bool(arg)
296
- end
297
-
298
- # check other options
299
-
300
- # initial_state
301
- # By default Nagios will assume that all hosts are in UP states when it starts.
302
- # You can override the initial state for a host by using this directive.
303
- # Valid options are:
304
- # o = UP,
305
- # d = DOWN,
306
- # u = UNREACHABLE.
307
- def initial_state=(arg)
308
- @initial_state = check_state_options(arg, %w(o d u), 'initail_state')
309
- end
310
-
311
- # flap_detection_options
312
- # This directive is used to determine what host states the flap detection logic will use for this host.
313
- # Valid options are a combination of one or more of the following:
314
- # o = UP states,
315
- # d = DOWN states,
316
- # u = UNREACHABLE states.
317
- def flap_detection_options=(arg)
318
- @flap_detection_options = check_state_options(arg, %w(o d u), 'flap_detection_options')
319
- end
320
-
321
- # stalking_options
322
- # This directive determines which host states "stalking" is enabled for.
323
- # Valid options are a combination of one or more of the following:
324
- # o = stalk on UP states,
325
- # d = stalk on DOWN states,
326
- # u = stalk on UNREACHABLE states.
327
- def stalking_options=(arg)
328
- @stalking_options = check_state_options(arg, %w(o d u), 'stalking_options')
329
- end
330
-
331
- # notification_options
332
- # This directive is used to determine when notifications for the host should be sent out.
333
- # Valid options are a combination of one or more of the following:
334
- # d = send notifications on a DOWN state,
335
- # u = send notifications on an UNREACHABLE state,
336
- # r = send notifications on recoveries (OK state),
337
- # f = send notifications when the host starts and stops flapping
338
- # s = send notifications when scheduled downtime starts and ends.
339
- # If you specify n (none) as an option, no host notifications will be sent out.
340
- # If you do not specify any notification options, Nagios will assume that you want notifications
341
- # to be sent out for all possible states.
342
- # Example: If you specify d,r in this field, notifications will only be sent out when the host
343
- # goes DOWN and when it recovers from a DOWN state.
344
-
345
- def notification_options=(arg)
346
- @notification_options = check_state_options(arg, %w(d u r f s n), 'notification_options')
347
- end
348
-
349
- private
350
-
351
- def config_options
352
- {
353
- 'name' => 'name',
354
- 'use' => 'use',
355
- 'host_name' => 'host_name',
356
- 'hostgroups_list' => 'hostgroups',
357
- 'alias' => 'alias',
358
- 'display_name' => 'display_name',
359
- 'address' => 'address',
360
- 'parents_list' => 'parents',
361
- 'check_command' => 'check_command',
362
- 'initial_state' => 'initial_state',
363
- 'max_check_attempts' => 'max_check_attempts',
364
- 'check_interval' => 'check_interval',
365
- 'retry_interval' => 'retry_interval',
366
- 'active_checks_enabled' => 'active_checks_enabled',
367
- 'passive_checks_enabled' => 'passive_checks_enabled',
368
- 'check_period' => 'check_period',
369
- 'obsess_over_host' => 'obsess_over_host',
370
- 'check_freshness' => 'check_freshness',
371
- 'freshness_threshold' => 'freshness_threshold',
372
- 'event_handler' => 'event_handler',
373
- 'event_handler_enabled' => 'event_handler_enabled',
374
- 'low_flap_threshold' => 'low_flap_threshold',
375
- 'high_flap_threshold' => 'high_flap_threshold',
376
- 'flap_detection_enabled' => 'flap_detection_enabled',
377
- 'flap_detection_options' => 'flap_detection_options',
378
- 'process_perf_data' => 'process_perf_data',
379
- 'retain_status_information' => 'retain_status_information',
380
- 'retain_nonstatus_information' => 'retain_nonstatus_information',
381
- 'contacts_list' => 'contacts',
382
- 'contact_groups_list' => 'contact_groups',
383
- 'notification_interval' => 'notification_interval',
384
- 'first_notification_delay' => 'first_notification_delay',
385
- 'notification_period' => 'notification_period',
386
- 'notification_options' => 'notification_options',
387
- 'notifications_enabled' => 'notifications_enabled',
388
- 'notifications' => nil,
389
- 'stalking_options' => 'stalking_options',
390
- 'notes' => 'notes',
391
- 'notes_url' => 'notes_url',
392
- 'action_url' => 'action_url',
393
- 'icon_image' => 'icon_image',
394
- 'icon_image_alt' => 'icon_image_alt',
395
- 'vrml_image' => 'vrml_image',
396
- 'statusmap_image' => 'statusmap_image',
397
- '_2d_coords' => '2d_coords',
398
- '_3d_coords' => '3d_coords',
399
- 'register' => 'register',
400
- }
401
- end
402
-
403
-
404
- def merge_members(obj)
405
- obj.parents.each { |m| push(m) }
406
- obj.contacts.each { |m| push(m) }
407
- obj.contact_groups.each { |m| push(m) }
408
- obj.hostgroups.each { |m| push(m) }
409
- obj.custom_options.each { |_, m| push(m) }
410
- end
411
- end
412
- end