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.
- checksums.yaml +5 -5
- data/Berksfile +4 -5
- data/Berksfile.lock +179 -0
- data/README.md +1 -6
- data/ansible/roles/geerlingguy.firewall/templates/firewall.bash.j2 +0 -0
- data/ansible/roles/mu-installer/README.md +33 -0
- data/ansible/roles/mu-installer/defaults/main.yml +2 -0
- data/ansible/roles/mu-installer/handlers/main.yml +2 -0
- data/ansible/roles/mu-installer/meta/main.yml +60 -0
- data/ansible/roles/mu-installer/tasks/main.yml +13 -0
- data/ansible/roles/mu-installer/tests/inventory +2 -0
- data/ansible/roles/mu-installer/tests/test.yml +5 -0
- data/ansible/roles/mu-installer/vars/main.yml +2 -0
- data/bin/mu-adopt +125 -0
- data/bin/mu-aws-setup +4 -4
- data/bin/mu-azure-setup +265 -0
- data/bin/mu-azure-tests +43 -0
- data/bin/mu-cleanup +20 -8
- data/bin/mu-configure +224 -98
- data/bin/mu-deploy +8 -3
- data/bin/mu-gcp-setup +16 -8
- data/bin/mu-gen-docs +92 -8
- data/bin/mu-load-config.rb +52 -12
- data/bin/mu-momma-cat +36 -0
- data/bin/mu-node-manage +34 -27
- data/bin/mu-self-update +2 -2
- data/bin/mu-ssh +12 -8
- data/bin/mu-upload-chef-artifacts +11 -4
- data/bin/mu-user-manage +3 -0
- data/cloud-mu.gemspec +8 -11
- data/cookbooks/firewall/libraries/helpers_iptables.rb +2 -2
- data/cookbooks/firewall/metadata.json +1 -1
- data/cookbooks/firewall/recipes/default.rb +5 -9
- data/cookbooks/mu-firewall/attributes/default.rb +2 -0
- data/cookbooks/mu-firewall/metadata.rb +1 -1
- data/cookbooks/mu-glusterfs/templates/default/mu-gluster-client.erb +0 -0
- data/cookbooks/mu-master/Berksfile +2 -2
- data/cookbooks/mu-master/files/default/check_mem.pl +0 -0
- data/cookbooks/mu-master/files/default/cloudamatic.png +0 -0
- data/cookbooks/mu-master/metadata.rb +5 -4
- data/cookbooks/mu-master/recipes/389ds.rb +1 -1
- data/cookbooks/mu-master/recipes/basepackages.rb +30 -10
- data/cookbooks/mu-master/recipes/default.rb +59 -7
- data/cookbooks/mu-master/recipes/firewall-holes.rb +1 -1
- data/cookbooks/mu-master/recipes/init.rb +65 -47
- data/cookbooks/mu-master/recipes/{eks-kubectl.rb → kubectl.rb} +4 -10
- data/cookbooks/mu-master/recipes/sssd.rb +2 -1
- data/cookbooks/mu-master/recipes/update_nagios_only.rb +6 -6
- data/cookbooks/mu-master/templates/default/web_app.conf.erb +2 -2
- data/cookbooks/mu-master/templates/mods/ldap.conf.erb +4 -0
- data/cookbooks/mu-php54/Berksfile +1 -2
- data/cookbooks/mu-php54/metadata.rb +4 -5
- data/cookbooks/mu-php54/recipes/default.rb +1 -1
- data/cookbooks/mu-splunk/templates/default/splunk-init.erb +0 -0
- data/cookbooks/mu-tools/Berksfile +3 -2
- data/cookbooks/mu-tools/files/default/Mu_CA.pem +33 -0
- data/cookbooks/mu-tools/libraries/helper.rb +20 -8
- data/cookbooks/mu-tools/metadata.rb +5 -2
- data/cookbooks/mu-tools/recipes/apply_security.rb +2 -3
- data/cookbooks/mu-tools/recipes/eks.rb +1 -1
- data/cookbooks/mu-tools/recipes/gcloud.rb +5 -30
- data/cookbooks/mu-tools/recipes/nagios.rb +1 -1
- data/cookbooks/mu-tools/recipes/rsyslog.rb +1 -0
- data/cookbooks/mu-tools/recipes/selinux.rb +19 -0
- data/cookbooks/mu-tools/recipes/split_var_partitions.rb +0 -1
- data/cookbooks/mu-tools/recipes/windows-client.rb +256 -122
- data/cookbooks/mu-tools/resources/disk.rb +3 -1
- data/cookbooks/mu-tools/templates/amazon/sshd_config.erb +1 -1
- data/cookbooks/mu-tools/templates/default/etc_hosts.erb +1 -1
- data/cookbooks/mu-tools/templates/default/{kubeconfig.erb → kubeconfig-eks.erb} +0 -0
- data/cookbooks/mu-tools/templates/default/kubeconfig-gke.erb +27 -0
- data/cookbooks/mu-tools/templates/windows-10/sshd_config.erb +137 -0
- data/cookbooks/mu-utility/recipes/nat.rb +4 -0
- data/extras/alpha.png +0 -0
- data/extras/beta.png +0 -0
- data/extras/clean-stock-amis +2 -2
- data/extras/generate-stock-images +131 -0
- data/extras/git-fix-permissions-hook +0 -0
- data/extras/image-generators/AWS/centos6.yaml +17 -0
- data/extras/image-generators/{aws → AWS}/centos7-govcloud.yaml +0 -0
- data/extras/image-generators/{aws → AWS}/centos7.yaml +0 -0
- data/extras/image-generators/{aws → AWS}/rhel7.yaml +0 -0
- data/extras/image-generators/{aws → AWS}/win2k12.yaml +0 -0
- data/extras/image-generators/{aws → AWS}/win2k16.yaml +0 -0
- data/extras/image-generators/{aws → AWS}/windows.yaml +0 -0
- data/extras/image-generators/{gcp → Google}/centos6.yaml +1 -0
- data/extras/image-generators/Google/centos7.yaml +18 -0
- data/extras/python_rpm/build.sh +0 -0
- data/extras/release.png +0 -0
- data/extras/ruby_rpm/build.sh +0 -0
- data/extras/ruby_rpm/muby.spec +1 -1
- data/install/README.md +43 -5
- data/install/deprecated-bash-library.sh +0 -0
- data/install/installer +1 -1
- data/install/jenkinskeys.rb +0 -0
- data/install/mu-master.yaml +55 -0
- data/modules/mommacat.ru +41 -7
- data/modules/mu.rb +444 -149
- data/modules/mu/adoption.rb +500 -0
- data/modules/mu/cleanup.rb +235 -158
- data/modules/mu/cloud.rb +675 -138
- data/modules/mu/clouds/aws.rb +156 -24
- data/modules/mu/clouds/aws/alarm.rb +4 -14
- data/modules/mu/clouds/aws/bucket.rb +60 -18
- data/modules/mu/clouds/aws/cache_cluster.rb +8 -20
- data/modules/mu/clouds/aws/collection.rb +12 -22
- data/modules/mu/clouds/aws/container_cluster.rb +209 -118
- data/modules/mu/clouds/aws/database.rb +120 -45
- data/modules/mu/clouds/aws/dnszone.rb +7 -18
- data/modules/mu/clouds/aws/endpoint.rb +5 -15
- data/modules/mu/clouds/aws/firewall_rule.rb +144 -72
- data/modules/mu/clouds/aws/folder.rb +4 -11
- data/modules/mu/clouds/aws/function.rb +6 -16
- data/modules/mu/clouds/aws/group.rb +4 -12
- data/modules/mu/clouds/aws/habitat.rb +11 -13
- data/modules/mu/clouds/aws/loadbalancer.rb +40 -28
- data/modules/mu/clouds/aws/log.rb +5 -13
- data/modules/mu/clouds/aws/msg_queue.rb +9 -24
- data/modules/mu/clouds/aws/nosqldb.rb +4 -12
- data/modules/mu/clouds/aws/notifier.rb +6 -13
- data/modules/mu/clouds/aws/role.rb +69 -40
- data/modules/mu/clouds/aws/search_domain.rb +17 -20
- data/modules/mu/clouds/aws/server.rb +184 -94
- data/modules/mu/clouds/aws/server_pool.rb +33 -38
- data/modules/mu/clouds/aws/storage_pool.rb +5 -12
- data/modules/mu/clouds/aws/user.rb +59 -33
- data/modules/mu/clouds/aws/userdata/linux.erb +18 -30
- data/modules/mu/clouds/aws/userdata/windows.erb +9 -9
- data/modules/mu/clouds/aws/vpc.rb +214 -145
- data/modules/mu/clouds/azure.rb +978 -44
- data/modules/mu/clouds/azure/container_cluster.rb +413 -0
- data/modules/mu/clouds/azure/firewall_rule.rb +500 -0
- data/modules/mu/clouds/azure/habitat.rb +167 -0
- data/modules/mu/clouds/azure/loadbalancer.rb +205 -0
- data/modules/mu/clouds/azure/role.rb +211 -0
- data/modules/mu/clouds/azure/server.rb +810 -0
- data/modules/mu/clouds/azure/user.rb +257 -0
- data/modules/mu/clouds/azure/userdata/README.md +4 -0
- data/modules/mu/clouds/azure/userdata/linux.erb +137 -0
- data/modules/mu/clouds/azure/userdata/windows.erb +275 -0
- data/modules/mu/clouds/azure/vpc.rb +782 -0
- data/modules/mu/clouds/cloudformation.rb +12 -9
- data/modules/mu/clouds/cloudformation/firewall_rule.rb +5 -13
- data/modules/mu/clouds/cloudformation/server.rb +10 -1
- data/modules/mu/clouds/cloudformation/server_pool.rb +1 -0
- data/modules/mu/clouds/cloudformation/vpc.rb +0 -2
- data/modules/mu/clouds/google.rb +554 -117
- data/modules/mu/clouds/google/bucket.rb +173 -32
- data/modules/mu/clouds/google/container_cluster.rb +1112 -157
- data/modules/mu/clouds/google/database.rb +24 -47
- data/modules/mu/clouds/google/firewall_rule.rb +344 -89
- data/modules/mu/clouds/google/folder.rb +156 -79
- data/modules/mu/clouds/google/group.rb +272 -82
- data/modules/mu/clouds/google/habitat.rb +177 -52
- data/modules/mu/clouds/google/loadbalancer.rb +9 -34
- data/modules/mu/clouds/google/role.rb +1211 -0
- data/modules/mu/clouds/google/server.rb +491 -227
- data/modules/mu/clouds/google/server_pool.rb +233 -48
- data/modules/mu/clouds/google/user.rb +479 -125
- data/modules/mu/clouds/google/userdata/linux.erb +3 -3
- data/modules/mu/clouds/google/userdata/windows.erb +9 -9
- data/modules/mu/clouds/google/vpc.rb +381 -223
- data/modules/mu/config.rb +689 -214
- data/modules/mu/config/bucket.rb +1 -1
- data/modules/mu/config/cache_cluster.rb +1 -1
- data/modules/mu/config/cache_cluster.yml +0 -4
- data/modules/mu/config/container_cluster.rb +18 -9
- data/modules/mu/config/database.rb +6 -23
- data/modules/mu/config/firewall_rule.rb +9 -15
- data/modules/mu/config/folder.rb +22 -21
- data/modules/mu/config/habitat.rb +22 -21
- data/modules/mu/config/loadbalancer.rb +2 -2
- data/modules/mu/config/role.rb +9 -40
- data/modules/mu/config/server.rb +26 -5
- data/modules/mu/config/server_pool.rb +1 -1
- data/modules/mu/config/storage_pool.rb +2 -2
- data/modules/mu/config/user.rb +4 -0
- data/modules/mu/config/vpc.rb +350 -110
- data/modules/mu/defaults/{amazon_images.yaml → AWS.yaml} +37 -39
- data/modules/mu/defaults/Azure.yaml +17 -0
- data/modules/mu/defaults/Google.yaml +24 -0
- data/modules/mu/defaults/README.md +1 -1
- data/modules/mu/deploy.rb +168 -125
- data/modules/mu/groomer.rb +2 -1
- data/modules/mu/groomers/ansible.rb +104 -32
- data/modules/mu/groomers/chef.rb +96 -44
- data/modules/mu/kittens.rb +20602 -0
- data/modules/mu/logger.rb +38 -11
- data/modules/mu/master.rb +90 -8
- data/modules/mu/master/chef.rb +2 -3
- data/modules/mu/master/ldap.rb +0 -1
- data/modules/mu/master/ssl.rb +250 -0
- data/modules/mu/mommacat.rb +917 -513
- data/modules/scratchpad.erb +1 -1
- data/modules/tests/super_complex_bok.yml +0 -0
- data/modules/tests/super_simple_bok.yml +0 -0
- data/roles/mu-master.json +2 -1
- data/spec/azure_creds +5 -0
- data/spec/mu.yaml +56 -0
- data/spec/mu/clouds/azure_spec.rb +164 -27
- data/spec/spec_helper.rb +5 -0
- data/test/clean_up.py +0 -0
- data/test/exec_inspec.py +0 -0
- data/test/exec_mu_install.py +0 -0
- data/test/exec_retry.py +0 -0
- data/test/smoke_test.rb +0 -0
- metadata +90 -118
- data/cookbooks/mu-jenkins/Berksfile +0 -14
- data/cookbooks/mu-jenkins/CHANGELOG.md +0 -13
- data/cookbooks/mu-jenkins/LICENSE +0 -37
- data/cookbooks/mu-jenkins/README.md +0 -105
- data/cookbooks/mu-jenkins/attributes/default.rb +0 -42
- data/cookbooks/mu-jenkins/files/default/cleanup_deploy_config.xml +0 -73
- data/cookbooks/mu-jenkins/files/default/deploy_config.xml +0 -44
- data/cookbooks/mu-jenkins/metadata.rb +0 -21
- data/cookbooks/mu-jenkins/recipes/default.rb +0 -195
- data/cookbooks/mu-jenkins/recipes/node-ssh-config.rb +0 -54
- data/cookbooks/mu-jenkins/recipes/public_key.rb +0 -24
- data/cookbooks/mu-jenkins/templates/default/example_job.config.xml.erb +0 -24
- data/cookbooks/mu-jenkins/templates/default/org.jvnet.hudson.plugins.SSHBuildWrapper.xml.erb +0 -14
- data/cookbooks/mu-jenkins/templates/default/ssh_config.erb +0 -6
- data/cookbooks/nagios/Berksfile +0 -11
- data/cookbooks/nagios/CHANGELOG.md +0 -589
- data/cookbooks/nagios/CONTRIBUTING.md +0 -11
- data/cookbooks/nagios/LICENSE +0 -37
- data/cookbooks/nagios/README.md +0 -328
- data/cookbooks/nagios/TESTING.md +0 -2
- data/cookbooks/nagios/attributes/config.rb +0 -171
- data/cookbooks/nagios/attributes/default.rb +0 -228
- data/cookbooks/nagios/chefignore +0 -102
- data/cookbooks/nagios/definitions/command.rb +0 -33
- data/cookbooks/nagios/definitions/contact.rb +0 -33
- data/cookbooks/nagios/definitions/contactgroup.rb +0 -33
- data/cookbooks/nagios/definitions/host.rb +0 -33
- data/cookbooks/nagios/definitions/hostdependency.rb +0 -33
- data/cookbooks/nagios/definitions/hostescalation.rb +0 -34
- data/cookbooks/nagios/definitions/hostgroup.rb +0 -33
- data/cookbooks/nagios/definitions/nagios_conf.rb +0 -38
- data/cookbooks/nagios/definitions/resource.rb +0 -33
- data/cookbooks/nagios/definitions/service.rb +0 -33
- data/cookbooks/nagios/definitions/servicedependency.rb +0 -33
- data/cookbooks/nagios/definitions/serviceescalation.rb +0 -34
- data/cookbooks/nagios/definitions/servicegroup.rb +0 -33
- data/cookbooks/nagios/definitions/timeperiod.rb +0 -33
- data/cookbooks/nagios/libraries/base.rb +0 -314
- data/cookbooks/nagios/libraries/command.rb +0 -91
- data/cookbooks/nagios/libraries/contact.rb +0 -230
- data/cookbooks/nagios/libraries/contactgroup.rb +0 -112
- data/cookbooks/nagios/libraries/custom_option.rb +0 -36
- data/cookbooks/nagios/libraries/data_bag_helper.rb +0 -23
- data/cookbooks/nagios/libraries/default.rb +0 -90
- data/cookbooks/nagios/libraries/host.rb +0 -412
- data/cookbooks/nagios/libraries/hostdependency.rb +0 -181
- data/cookbooks/nagios/libraries/hostescalation.rb +0 -173
- data/cookbooks/nagios/libraries/hostgroup.rb +0 -119
- data/cookbooks/nagios/libraries/nagios.rb +0 -282
- data/cookbooks/nagios/libraries/resource.rb +0 -59
- data/cookbooks/nagios/libraries/service.rb +0 -455
- data/cookbooks/nagios/libraries/servicedependency.rb +0 -215
- data/cookbooks/nagios/libraries/serviceescalation.rb +0 -195
- data/cookbooks/nagios/libraries/servicegroup.rb +0 -144
- data/cookbooks/nagios/libraries/timeperiod.rb +0 -160
- data/cookbooks/nagios/libraries/users_helper.rb +0 -54
- data/cookbooks/nagios/metadata.rb +0 -25
- data/cookbooks/nagios/recipes/_load_databag_config.rb +0 -153
- data/cookbooks/nagios/recipes/_load_default_config.rb +0 -241
- data/cookbooks/nagios/recipes/apache.rb +0 -48
- data/cookbooks/nagios/recipes/default.rb +0 -204
- data/cookbooks/nagios/recipes/nginx.rb +0 -82
- data/cookbooks/nagios/recipes/pagerduty.rb +0 -143
- data/cookbooks/nagios/recipes/server_package.rb +0 -40
- data/cookbooks/nagios/recipes/server_source.rb +0 -164
- data/cookbooks/nagios/templates/default/apache2.conf.erb +0 -96
- data/cookbooks/nagios/templates/default/cgi.cfg.erb +0 -266
- data/cookbooks/nagios/templates/default/commands.cfg.erb +0 -13
- data/cookbooks/nagios/templates/default/contacts.cfg.erb +0 -37
- data/cookbooks/nagios/templates/default/hostgroups.cfg.erb +0 -25
- data/cookbooks/nagios/templates/default/hosts.cfg.erb +0 -15
- data/cookbooks/nagios/templates/default/htpasswd.users.erb +0 -6
- data/cookbooks/nagios/templates/default/nagios.cfg.erb +0 -22
- data/cookbooks/nagios/templates/default/nginx.conf.erb +0 -62
- data/cookbooks/nagios/templates/default/pagerduty.cgi.erb +0 -185
- data/cookbooks/nagios/templates/default/resource.cfg.erb +0 -27
- data/cookbooks/nagios/templates/default/servicedependencies.cfg.erb +0 -15
- data/cookbooks/nagios/templates/default/servicegroups.cfg.erb +0 -14
- data/cookbooks/nagios/templates/default/services.cfg.erb +0 -14
- data/cookbooks/nagios/templates/default/templates.cfg.erb +0 -31
- data/cookbooks/nagios/templates/default/timeperiods.cfg.erb +0 -13
- data/extras/image-generators/aws/centos6.yaml +0 -18
- data/modules/mu/defaults/google_images.yaml +0 -16
- 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
|