OSDN Git Service

updates dcos roles.
[metasearch/grid-chef-repo.git] / roles / praesepe-gm.rb
1 #
2 # Copyright 2013-2014, whitestar
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16
17 $LOAD_PATH.push("#{File.dirname(__FILE__)}/_lib")
18 #${chef-repo}/roles/_lib/grid.rb
19 require 'grid'
20 require 'rubygems'
21 require 'bracecomp'
22
23 cluster_name = 'praesepe'
24 cluster_sym = cluster_name.to_sym
25 datanode_prefix = 'dn1'
26 datanode_digit_nums = 4
27
28 name "#{cluster_name}-gm"
29 description "#{cluster_name.capitalize} ganglia gmetad node"
30
31 run_list(
32   'role[node_commons]',
33   #'role[nameservice-client-grid]',
34   'role[ganglia-gmond]',
35   'role[ganglia-gmetad]',
36   'role[ganglia-web]'
37 )
38
39 #env_run_lists()
40
41 this_subcluster = Grid::CLUSTERS[cluster_sym][:gmetads]
42 mcast_addr = this_subcluster[:mcast_addr]
43 port = '8649'
44 polling_interval = '30'
45 # uni-cast
46 udp_send_channels4ucast = []
47 this_subcluster[:nodes].first(2).each {|host|
48   udp_send_channels4ucast.push(
49     {
50       'mcast_join' => '',
51       'host' => "#{host}.#{Grid::DOMAIN}",
52       'port' => port,
53       'ttl' => ''
54     }
55   )
56 }
57
58 # for non-DataNodes
59 data_sources = []
60 Grid::CLUSTERS[cluster_sym].select{|key| key != :datanodes}.each {|key, cluster|
61   data_sources.push(
62     {
63       :name => cluster[:alias],
64       :polling_interval => polling_interval,
65       # head nodes: 2
66       :address_list => cluster[:nodes].first(2).map{|host| "#{host}.#{Grid::DOMAIN}"}
67     }
68   )
69 }
70
71 # for DataNodes
72 head_node_nums = 2
73 digit_nums = datanode_digit_nums
74 padstr = '0'
75 dn_data_sources = []
76 (0...2).step(40) {|v|
77 #(0...80).step(40) {|v|
78   first_head = v.to_s.rjust(digit_nums, padstr)
79   last_head = (v + head_node_nums -1).to_s.rjust(digit_nums, padstr)
80   dn_data_sources.push( 
81     {
82       :name => "DataNode#{first_head}",
83       :polling_interval => polling_interval,
84       # dn10000
85       :address_list => "#{datanode_prefix}{#{first_head}..#{last_head}}.#{Grid::DOMAIN}".expand
86     }
87   )
88 }
89
90 default_attributes(
91   'ganglia' => {
92     'web' => {
93 =begin
94       'Allow' => [
95         "from .#{Grid::DOMAIN}",
96         'from 192.168.0.0/16'],
97       'AuthType' => 'Kerberos',
98       'mod_auth_kerb' => {
99         'KrbAuthRealms' => Grid::REALM,
100         'Krb5Keytab' => '/etc/krb5.keytab'
101       }
102 =end
103     }
104   },
105 )
106
107 nagios_nodes = []
108 if defined? Grid::CLUSTERS[cluster_sym][:nagioses][:nodes] then
109   nagios_nodes = Grid::CLUSTERS[cluster_sym][:nagioses][:nodes].map{|host| "#{host}.#{Grid::DOMAIN}"}
110 end
111
112 override_attributes(
113   'ganglia' => {
114     # gmond
115     'cluster' => {
116       'name' => this_subcluster[:alias],
117       'owner' => Grid::DOMAIN
118     },
119     'static' => {
120 =begin
121       ## static multi-cast
122       'udp_send_channels' => [
123         {
124           'mcast_join' => mcast_addr,
125           'host' => '',
126           'port' => port,
127           'ttl' => '1'
128         }
129       ],
130       'udp_recv_channels' => [
131         {
132           'mcast_join' => mcast_addr,
133           'port' => port,
134           'bind' => mcast_addr
135         }
136       ],
137 =end
138       ## static uni-cast
139       'udp_send_channels' => udp_send_channels4ucast,
140       'udp_recv_channels' => [
141         {
142           'mcast_join' => '',
143           'port' => port,
144           'bind' => ''
145         }
146       ],
147     },
148     # gmetad
149     'gridname' => cluster_name.capitalize,
150     'trusted_hosts' => ['127.0.0.1'] + nagios_nodes,
151     'data_sources' => data_sources + dn_data_sources
152   }
153 )