OSDN Git Service

add .envrc
[metasearch/grid-chef-repo.git] / roles / pleiades-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 = 'pleiades'
24 cluster_sym = cluster_name.to_sym
25
26 name "#{cluster_name}-gm"
27 description "#{cluster_name.capitalize} ganglia gmetad node"
28
29 run_list(
30   'role[node_commons]',
31   'role[nameservice-client-grid]',
32   'role[ganglia-gmond]',
33   'role[ganglia-gmetad]',
34   'role[ganglia-web]'
35 )
36
37 #env_run_lists()
38
39 this_subcluster = Grid::CLUSTERS[cluster_sym][:gmetads]
40 mcast_addr = this_subcluster[:mcast_addr]
41 port = '8649'
42 polling_interval = '30'
43 =begin
44 # uni-cast
45 udp_send_channels4ucast = []
46 this_subcluster[:nodes].first(2).each {|host|
47   udp_send_channels4ucast.push(
48     {
49       'mcast_join' => '',
50       'host' => "#{host}.#{Grid::DOMAIN}",
51       'port' => port,
52       'ttl' => ''
53     }
54   )
55 }
56 =end
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 = 5
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       :address_list => "dn{#{first_head}..#{last_head}}.#{Grid::DOMAIN}".expand
85     }
86   )
87 }
88
89 default_attributes(
90   'ganglia' => {
91     'web' => {
92       'Allow' => [
93         "from .#{Grid::DOMAIN}",
94         'from 192.168.0.0/16'],
95       'AuthType' => 'Kerberos',
96       'mod_auth_kerb' => {
97         'KrbAuthRealms' => Grid::REALM,
98         'Krb5Keytab' => '/etc/krb5.keytab'
99       }
100     }
101   },
102 )
103
104 nagios_nodes = []
105 if defined? Grid::CLUSTERS[cluster_sym][:nagioses][:nodes] then
106   nagios_nodes = Grid::CLUSTERS[cluster_sym][:nagioses][:nodes].map{|host| "#{host}.#{Grid::DOMAIN}"}
107 end
108
109 override_attributes(
110   'ganglia' => {
111     # gmond
112     'cluster' => {
113       'name' => this_subcluster[:alias],
114       'owner' => Grid::DOMAIN
115     },
116     ## static multi-cast
117     'static' => {
118       'udp_send_channels' => [
119         {
120           'mcast_join' => mcast_addr,
121           'host' => '',
122           'port' => port,
123           'ttl' => '1'
124         }
125       ],
126       'udp_recv_channels' => [
127         {
128           'mcast_join' => mcast_addr,
129           'port' => port,
130           'bind' => mcast_addr
131         }
132       ],
133 =begin
134       ## static uni-cast
135       'udp_send_channels' => udp_send_channels4ucast,
136       'udp_recv_channels' => [
137         {
138           'mcast_join' => '',
139           'port' => port,
140           'bind' => ''
141         }
142       ],
143 =end
144     },
145     # gmetad
146     'gridname' => 'Pleiades',
147     'trusted_hosts' => ['127.0.0.1'] + nagios_nodes,
148     'data_sources' => data_sources + dn_data_sources
149   }
150 )