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,160 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name:: nagios
4
- # Library:: timeperiod
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 timeperiodentries,
25
- # that are used within the timeperiod nagios configurations.
26
- #
27
- class Timeperiodentry
28
- attr_reader :moment,
29
- :period
30
-
31
- def initialize(moment, period)
32
- @moment = moment
33
- @period = check_period(period)
34
- end
35
-
36
- def to_s
37
- moment
38
- end
39
-
40
- private
41
-
42
- def check_period(period)
43
- return period if period =~ /^(([01]?[0-9]|2[0-3])\:[0-5][0-9]-([01]?[0-9]|2[0-4])\:[0-5][0-9],?)*$/
44
- nil
45
- end
46
- end
47
-
48
- #
49
- # This class holds all methods with regard to timeperiod options,
50
- # that are used within nagios configurations.
51
- #
52
- class Timeperiod < Nagios::Base
53
- attr_reader :timeperiod_name
54
-
55
- attr_accessor :alias,
56
- :periods,
57
- :exclude
58
-
59
- def initialize(timeperiod_name)
60
- @timeperiod_name = timeperiod_name
61
- @periods = {}
62
- @exclude = {}
63
- super()
64
- end
65
-
66
- def self.create(name)
67
- Nagios.instance.find(Nagios::Timeperiod.new(name))
68
- end
69
-
70
- def definition
71
- configured = configured_options
72
- periods.values.each { |v| configured[v.moment] = v.period }
73
- get_definition(configured, 'timeperiod')
74
- end
75
-
76
- # exclude
77
- # This directive is used to specify the short names of other timeperiod definitions
78
- # whose time ranges should be excluded from this timeperiod.
79
- # Multiple timeperiod names should be separated with a comma.
80
-
81
- def exclude
82
- @exclude.values.map(&:to_s).sort.join(',')
83
- end
84
-
85
- def import(hash)
86
- update_options(hash)
87
- if hash['times'].respond_to?('each_pair')
88
- hash['times'].each { |k, v| push(Nagios::Timeperiodentry.new(k, v)) }
89
- end
90
- update_members(hash, 'exclude', Nagios::Timeperiod)
91
- end
92
-
93
- def push(obj)
94
- case obj
95
- when Nagios::Timeperiod
96
- push_object(obj, @exclude)
97
- when Nagios::Timeperiodentry
98
- push_object(obj, @periods) unless obj.period.nil?
99
- end
100
- end
101
-
102
- def pop(obj)
103
- return if obj == self
104
- case obj
105
- when Nagios::Timeperiod
106
- if @exclude.keys?(obj.to_s)
107
- pop_object(obj, @exclude)
108
- pop(self, obj)
109
- end
110
- when Nagios::Timeperiodentry
111
- if @periods.keys?(obj.to_s)
112
- pop_object(obj, @periods)
113
- pop(self, obj)
114
- end
115
- end
116
- end
117
-
118
-
119
- def to_s
120
- timeperiod_name
121
- end
122
-
123
- # [weekday]
124
- # The weekday directives ("sunday" through "saturday")are comma-delimited
125
- # lists of time ranges that are "valid" times for a particular day of the week.
126
- # Notice that there are seven different days for which you can define time
127
- # ranges (Sunday through Saturday). Each time range is in the form of
128
- # HH:MM-HH:MM, where hours are specified on a 24 hour clock.
129
- # For example, 00:15-24:00 means 12:15am in the morning for this day until
130
- # 12:00am midnight (a 23 hour, 45 minute total time range).
131
- # If you wish to exclude an entire day from the timeperiod, simply do not include
132
- # it in the timeperiod definition.
133
-
134
- # [exception]
135
- # You can specify several different types of exceptions to the standard rotating
136
- # weekday schedule. Exceptions can take a number of different forms including single
137
- # days of a specific or generic month, single weekdays in a month, or single calendar
138
- # dates. You can also specify a range of days/dates and even specify skip intervals
139
- # to obtain functionality described by "every 3 days between these dates".
140
- # Rather than list all the possible formats for exception strings, I'll let you look
141
- # at the example timeperiod definitions above to see what's possible.
142
- # Weekdays and different types of exceptions all have different levels of precedence,
143
- # so its important to understand how they can affect each other.
144
-
145
- private
146
-
147
- def config_options
148
- {
149
- 'timeperiod_name' => 'timeperiod_name',
150
- 'alias' => 'alias',
151
- 'exclude' => 'exclude',
152
- }
153
- end
154
-
155
- def merge_members(obj)
156
- obj.periods.each { |m| push(m) }
157
- obj.exclude.each { |m| push(m) }
158
- end
159
- end
160
- end
@@ -1,54 +0,0 @@
1
- require 'chef/log'
2
- require 'chef/search/query'
3
-
4
- # Simplify access to list of all valid Nagios users
5
- class NagiosUsers
6
- attr_accessor :users
7
-
8
- def initialize(node)
9
- @node = node
10
- @users = []
11
-
12
- user_databag = node['nagios']['users_databag'].to_sym
13
- group = node['nagios']['users_databag_group']
14
-
15
- if node['nagios']['server']['use_encrypted_data_bags']
16
- load_encrypted_databag(user_databag)
17
- else
18
- search_databag(user_databag, group)
19
- end
20
- end
21
-
22
- def return_user_contacts
23
- contacts = []
24
- # add base contacts from nagios_users data bag
25
- @users.each do |s|
26
- contacts << s['id']
27
- end
28
- contacts
29
- end
30
-
31
- private
32
-
33
- def fail_search(user_databag)
34
- Chef::Log.fatal("\"#{user_databag}\" databag could not be found.")
35
- raise "\"#{user_databag}\" databag could not be found."
36
- end
37
-
38
- def load_encrypted_databag(user_databag)
39
- Chef::DataBag.load(user_databag).each do |u, _|
40
- d = Chef::EncryptedDataBagItem.load(user_databag, u) # ~FC086
41
- @users << d unless d['nagios'].nil? || d['nagios']['email'].nil?
42
- end
43
- rescue Net::HTTPServerException
44
- fail_search(user_databag)
45
- end
46
-
47
- def search_databag(user_databag, group)
48
- Chef::Search::Query.new.search(user_databag, "groups:#{group} NOT action:remove") do |d|
49
- @users << d unless d['nagios'].nil? || d['nagios']['email'].nil?
50
- end
51
- rescue Net::HTTPServerException
52
- fail_search(user_databag)
53
- end
54
- end
@@ -1,25 +0,0 @@
1
- name 'nagios'
2
- maintainer 'Mu'
3
- maintainer_email 'mu-developers@googlegroups.com'
4
- license 'BSD-3-Clause'
5
- description 'Installs and configures Nagios server'
6
- long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7
- version '7.2.7'
8
- source_url 'https://github.com/cloudamatic/mu'
9
- issues_url 'https://github.com/cloudamatic/mu/issues'
10
- chef_version '>= 14.0' if respond_to?(:chef_version)
11
-
12
- recipe 'default', 'Installs Nagios server.'
13
- recipe 'nagios::pagerduty', 'Integrates contacts w/ PagerDuty API'
14
-
15
- depends 'apache2', '< 4.0'
16
- depends 'php', '< 6.0'
17
- depends 'zap', '>= 0.6.0'
18
-
19
- %w(chef_nginx nginx_simplecgi yum-epel nrpe ).each do |cb|
20
- depends cb
21
- end
22
-
23
- %w( debian ubuntu redhat centos fedora scientific amazon oracle).each do |os|
24
- supports os
25
- end
@@ -1,153 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name:: nagios
4
- # Recipe:: _load_databag_config
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
- # Loading all databag information
21
- nagios_bags = NagiosDataBags.new
22
-
23
- hostgroups = nagios_bags.get(node['nagios']['hostgroups_databag'])
24
- hostgroups.each do |group|
25
- next if group['search_query'].nil?
26
- if node['nagios']['multi_environment_monitoring']
27
- query_environments = node['nagios']['monitored_environments'].map do |environment|
28
- "chef_environment:#{environment}"
29
- end.join(' OR ')
30
- result = search(:node, "(#{group['search_query']}) AND (#{query_environments})")
31
- else
32
- result = search(:node, "#{group['search_query']} AND chef_environment:#{node.chef_environment}")
33
- end
34
-
35
- result.each do |n|
36
- n.automatic_attrs['roles'] = [group['hostgroup_name']]
37
- Nagios.instance.push(n)
38
- end
39
- end
40
-
41
- services = nagios_bags.get(node['nagios']['services_databag'])
42
- services.each do |item|
43
- next unless item['activate_check_in_environment'].nil? || item['activate_check_in_environment'].include?(node.chef_environment)
44
- name = item['service_description'] || item['id']
45
- check_command = name.downcase.start_with?('check_') ? name.downcase : 'check_' + name.downcase
46
- command_name = item['check_command'].nil? ? check_command : item['check_command']
47
- service_name = name.downcase.start_with?('check_') ? name.gsub('check_', '') : name.downcase
48
- item['check_command'] = command_name
49
-
50
- nagios_command command_name do
51
- options item
52
- end
53
-
54
- nagios_service service_name do
55
- options item
56
- end
57
- end
58
-
59
- contactgroups = nagios_bags.get(node['nagios']['contactgroups_databag'])
60
- contactgroups.each do |item|
61
- name = item['contactgroup_name'] || item['id']
62
- nagios_contactgroup name do
63
- options item
64
- end
65
- end
66
-
67
- eventhandlers = nagios_bags.get(node['nagios']['eventhandlers_databag'])
68
- eventhandlers.each do |item|
69
- name = item['command_name'] || item['id']
70
- nagios_command name do
71
- options item
72
- end
73
- end
74
-
75
- contacts = nagios_bags.get(node['nagios']['contacts_databag'])
76
- contacts.each do |item|
77
- name = item['contact_name'] || item['id']
78
- nagios_contact name do
79
- options item
80
- end
81
- end
82
-
83
- hostescalations = nagios_bags.get(node['nagios']['hostescalations_databag'])
84
- hostescalations.each do |item|
85
- name = item['host_description'] || item['id']
86
- nagios_hostescalation name do
87
- options item
88
- end
89
- end
90
-
91
- hosttemplates = nagios_bags.get(node['nagios']['hosttemplates_databag'])
92
- hosttemplates.each do |item|
93
- name = item['host_name'] || item['id']
94
- item['name'] = name if item['name'].nil?
95
- nagios_host name do
96
- options item
97
- end
98
- end
99
-
100
- servicedependencies = nagios_bags.get(node['nagios']['servicedependencies_databag'])
101
- servicedependencies.each do |item|
102
- name = item['service_description'] || item['id']
103
- nagios_servicedependency name do
104
- options item
105
- end
106
- end
107
-
108
- serviceescalations = nagios_bags.get(node['nagios']['serviceescalations_databag'])
109
- serviceescalations.each do |item|
110
- name = item['service_description'] || item['id']
111
- nagios_serviceescalation name do
112
- options item
113
- end
114
- end
115
-
116
- servicegroups = nagios_bags.get(node['nagios']['servicegroups_databag'])
117
- servicegroups.each do |item|
118
- name = item['servicegroup_name'] || item['id']
119
- nagios_servicegroup name do
120
- options item
121
- end
122
- end
123
-
124
- templates = nagios_bags.get(node['nagios']['templates_databag'])
125
- templates.each do |item|
126
- name = item['name'] || item['id']
127
- item['name'] = name
128
- nagios_service name do
129
- options item
130
- end
131
- end
132
-
133
- timeperiods = nagios_bags.get(node['nagios']['timeperiods_databag'])
134
- timeperiods.each do |item|
135
- name = item['timeperiod_name'] || item['id']
136
- nagios_timeperiod name do
137
- options item
138
- end
139
- end
140
-
141
- unmanaged_hosts = nagios_bags.get(node['nagios']['unmanagedhosts_databag'])
142
- unmanaged_hosts.each do |item|
143
- if node['nagios']['multi_environment_monitoring'].nil?
144
- next if item['environment'].nil? || item['environment'] != node.chef_environment
145
- else
146
- envs = node['nagios']['monitored_environments']
147
- next if item['environment'].nil? || !envs.include?(item['environment'])
148
- end
149
- name = item['host_name'] || item['id']
150
- nagios_host name do
151
- options item
152
- end
153
- end
@@ -1,241 +0,0 @@
1
- #
2
- # Author:: Sander Botman <sbotman@schubergphilis.com>
3
- # Cookbook Name:: nagios
4
- # Recipe:: _load_default_config
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
- # Find nodes to monitor.
21
- # Search in all environments if multi_environment_monitoring is enabled.
22
- Chef::Log.info('Beginning search for nodes. This may take some time depending on your node count')
23
-
24
- multi_env = node['nagios']['monitored_environments']
25
- multi_env_search = multi_env.empty? ? '' : ' AND (chef_environment:' + multi_env.join(' OR chef_environment:') + ')'
26
-
27
- nodes = if node['nagios']['multi_environment_monitoring']
28
- search(:node, "name:*#{multi_env_search}")
29
- else
30
- search(:node, "name:* AND chef_environment:#{node.chef_environment}")
31
- end
32
-
33
- if nodes.empty?
34
- Chef::Log.info('No nodes returned from search, using this node so hosts.cfg has data')
35
- nodes << node
36
- end
37
-
38
- # Pushing current node to prevent empty hosts.cfg
39
- Nagios.instance.push(node)
40
-
41
- # Pushing all nodes into the Nagios.instance model
42
- exclude_tag = nagios_array(node['nagios']['exclude_tag_host'])
43
- nodes.each do |n|
44
- if n.respond_to?('tags')
45
- Nagios.instance.push(n) unless nagios_array(n.tags).any? { |tag| exclude_tag.include?(tag) }
46
- else
47
- Nagios.instance.push(n)
48
- end
49
- end
50
-
51
- # 24x7 timeperiod
52
- nagios_timeperiod '24x7' do
53
- options 'alias' => '24 Hours A Day, 7 Days A Week',
54
- 'times' => { 'sunday' => '00:00-24:00',
55
- 'monday' => '00:00-24:00',
56
- 'tuesday' => '00:00-24:00',
57
- 'wednesday' => '00:00-24:00',
58
- 'thursday' => '00:00-24:00',
59
- 'friday' => '00:00-24:00',
60
- 'saturday' => '00:00-24:00',
61
- }
62
- end
63
-
64
- # Host checks
65
- nagios_command 'check_host_alive' do
66
- options 'command_line' => '$USER1$/check_ping -H $HOSTADDRESS$ -w 2000,80% -c 3000,100% -p 1'
67
- end
68
-
69
- # Service checks
70
- nagios_command 'check_nagios' do
71
- options 'command_line' => '$USER1$/check_nrpe -H $HOSTADDRESS$ -c check_nagios -t 20'
72
- end
73
-
74
- # nrpe remote host checks
75
- nagios_command 'check_nrpe_alive' do
76
- options 'command_line' => '$USER1$/check_nrpe -H $HOSTADDRESS$ -t 20'
77
- end
78
-
79
- nagios_command 'check_nrpe' do
80
- options 'command_line' => '$USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -t 20'
81
- end
82
-
83
- # host_notify_by_email command
84
- nagios_command 'host_notify_by_email' do
85
- options 'command_line' => '/usr/bin/printf "%b" "$LONGDATETIME$\n\n$HOSTALIAS$ $NOTIFICATIONTYPE$ $HOSTSTATE$\n\n$HOSTOUTPUT$\n\nLogin: ssh://$HOSTNAME$" | ' + node['nagios']['server']['mail_command'] + ' -s "$NOTIFICATIONTYPE$ - $HOSTALIAS$ $HOSTSTATE$!" $CONTACTEMAIL$'
86
- end
87
-
88
- # service_notify_by_email command
89
- nagios_command 'service_notify_by_email' do
90
- options 'command_line' => '/usr/bin/printf "%b" "$LONGDATETIME$ - $SERVICEDESC$ $SERVICESTATE$\n\n$HOSTALIAS$ $NOTIFICATIONTYPE$\n\n$SERVICEOUTPUT$\n\nLogin: ssh://$HOSTNAME$" | ' + node['nagios']['server']['mail_command'] + ' -s "** $NOTIFICATIONTYPE$ - $HOSTALIAS$ - $SERVICEDESC$ - $SERVICESTATE$" $CONTACTEMAIL$'
91
- end
92
-
93
- # host_notify_by_sms_email command
94
- nagios_command 'host_notify_by_sms_email' do
95
- options 'command_line' => '/usr/bin/printf "%b" "$HOSTALIAS$ $NOTIFICATIONTYPE$ $HOSTSTATE$\n\n$HOSTOUTPUT$" | ' + node['nagios']['server']['mail_command'] + ' -s "$HOSTALIAS$ $HOSTSTATE$!" $CONTACTPAGER$'
96
- end
97
-
98
- # service_notify_by_sms_email command
99
- nagios_command 'service_notify_by_sms_email' do
100
- options 'command_line' => '/usr/bin/printf "%b" "$SERVICEDESC$ $NOTIFICATIONTYPE$ $SERVICESTATE$\n\n$SERVICEOUTPUT$" | ' + node['nagios']['server']['mail_command'] + ' -s "$HOSTALIAS$ $SERVICEDESC$ $SERVICESTATE$!" $CONTACTPAGER$'
101
- end
102
-
103
- # root contact
104
- nagios_contact 'root' do
105
- options 'alias' => 'Root',
106
- 'service_notification_period' => '24x7',
107
- 'host_notification_period' => '24x7',
108
- 'service_notification_options' => 'w,u,c,r',
109
- 'host_notification_options' => 'd,r',
110
- 'service_notification_commands' => 'service_notify_by_email',
111
- 'host_notification_commands' => 'host_notify_by_email',
112
- 'email' => 'root@localhost'
113
- end
114
-
115
- # admin contact
116
- nagios_contact 'admin' do
117
- options 'alias' => 'Admin',
118
- 'service_notification_period' => '24x7',
119
- 'host_notification_period' => '24x7',
120
- 'service_notification_options' => 'w,u,c,r',
121
- 'host_notification_options' => 'd,r',
122
- 'service_notification_commands' => 'service_notify_by_email',
123
- 'host_notification_commands' => 'host_notify_by_email'
124
- end
125
-
126
- nagios_contact 'default-contact' do
127
- options 'name' => 'default-contact',
128
- 'service_notification_period' => '24x7',
129
- 'host_notification_period' => '24x7',
130
- 'service_notification_options' => 'w,u,c,r,f',
131
- 'host_notification_options' => 'd,u,r,f,s',
132
- 'service_notification_commands' => 'service_notify_by_email',
133
- 'host_notification_commands' => 'host_notify_by_email'
134
- end
135
-
136
- nagios_host 'default-host' do
137
- options 'name' => 'default-host',
138
- 'notifications_enabled' => 1,
139
- 'event_handler_enabled' => 1,
140
- 'flap_detection_enabled' => nagios_boolean(nagios_attr(:default_host)[:flap_detection]),
141
- 'process_perf_data' => nagios_boolean(nagios_attr(:default_host)[:process_perf_data]),
142
- 'retain_status_information' => 1,
143
- 'retain_nonstatus_information' => 1,
144
- 'notification_period' => '24x7',
145
- 'register' => 0,
146
- 'action_url' => nagios_attr(:default_host)[:action_url]
147
- end
148
-
149
- nagios_host 'server' do
150
- options 'name' => 'server',
151
- 'use' => 'default-host',
152
- 'check_period' => nagios_attr(:default_host)[:check_period],
153
- 'check_interval' => nagios_interval(nagios_attr(:default_host)[:check_interval]),
154
- 'retry_interval' => nagios_interval(nagios_attr(:default_host)[:retry_interval]),
155
- 'max_check_attempts' => nagios_attr(:default_host)[:max_check_attempts],
156
- 'check_command' => nagios_attr(:default_host)[:check_command],
157
- 'notification_interval' => nagios_interval(nagios_attr(:default_host)[:notification_interval]),
158
- 'notification_options' => nagios_attr(:default_host)[:notification_options],
159
- 'contact_groups' => nagios_attr(:default_contact_groups),
160
- 'register' => 0
161
- end
162
-
163
- # Defaut host template
164
- Nagios.instance.default_host = node['nagios']['host_template']
165
-
166
- # Users
167
- # use the users_helper.rb library to build arrays of users and contacts
168
- nagios_users = NagiosUsers.new(node)
169
- nagios_users.users.each do |item|
170
- o = Nagios::Contact.create(item['id'])
171
- o.import(item.to_hash)
172
- o.import(item['nagios'].to_hash) unless item['nagios'].nil?
173
- o.use = 'default-contact'
174
- end
175
-
176
- nagios_contactgroup 'admins' do
177
- options 'alias' => 'Nagios Administrators',
178
- 'members' => nagios_users.return_user_contacts
179
- end
180
-
181
- nagios_contactgroup 'admins-sms' do
182
- options 'alias' => 'Sysadmin SMS',
183
- 'members' => nagios_users.return_user_contacts
184
- end
185
-
186
- # Services
187
- nagios_service 'default-service' do
188
- options 'name' => 'default-service',
189
- 'active_checks_enabled' => 1,
190
- 'passive_checks_enabled' => 1,
191
- 'parallelize_check' => 1,
192
- 'obsess_over_service' => 1,
193
- 'check_freshness' => 0,
194
- 'notifications_enabled' => 1,
195
- 'event_handler_enabled' => 1,
196
- 'flap_detection_enabled' => nagios_boolean(nagios_attr(:default_service)[:flap_detection]),
197
- 'process_perf_data' => nagios_boolean(nagios_attr(:default_service)[:process_perf_data]),
198
- 'retain_status_information' => 1,
199
- 'retain_nonstatus_information' => 1,
200
- 'is_volatile' => 0,
201
- 'check_period' => '24x7',
202
- 'max_check_attempts' => nagios_attr(:default_service)[:max_check_attempts],
203
- 'check_interval' => nagios_interval(nagios_attr(:default_service)[:check_interval]),
204
- 'retry_interval' => nagios_interval(nagios_attr(:default_service)[:retry_interval]),
205
- 'contact_groups' => nagios_attr(:default_contact_groups),
206
- 'notification_options' => 'w,u,c,r',
207
- 'notification_interval' => nagios_interval(nagios_attr(:default_service)[:notification_interval]),
208
- 'notification_period' => '24x7',
209
- 'register' => 0,
210
- 'action_url' => nagios_attr(:default_service)[:action_url]
211
- end
212
- # Default service template
213
- Nagios.instance.default_service = 'default-service'
214
-
215
- # Define the log monitoring template (monitoring logs is very different)
216
- nagios_service 'default-logfile' do
217
- options 'name' => 'default-logfile',
218
- 'use' => 'default-service',
219
- 'check_period' => '24x7',
220
- 'max_check_attempts' => 1,
221
- 'check_interval' => nagios_interval(nagios_attr(:default_service)[:check_interval]),
222
- 'retry_interval' => nagios_interval(nagios_attr(:default_service)[:retry_interval]),
223
- 'contact_groups' => nagios_attr(:default_contact_groups),
224
- 'notification_options' => 'w,u,c,r',
225
- 'notification_period' => '24x7',
226
- 'register' => 0,
227
- 'is_volatile' => 1
228
- end
229
-
230
- nagios_service 'service-template' do
231
- options 'name' => 'service-template',
232
- 'max_check_attempts' => nagios_attr(:default_service)[:max_check_attempts],
233
- 'check_interval' => nagios_interval(nagios_attr(:default_service)[:check_interval]),
234
- 'retry_interval' => nagios_interval(nagios_attr(:default_service)[:retry_interval]),
235
- 'notification_interval' => nagios_interval(nagios_attr(:default_service)[:notification_interval]),
236
- 'register' => 0
237
- end
238
-
239
- nagios_resource 'USER1' do
240
- options 'value' => node['nagios']['plugin_dir']
241
- end