OSDN Git Service

refactor roles.
[metasearch/grid-chef-repo.git] / roles / pleiades-gm.rb
1 $LOAD_PATH.push("#{File.dirname(__FILE__)}/../_lib")
2 #${chef-repo}/_lib/grid.rb
3 require 'grid'
4 require 'rubygems'
5 require 'bracecomp'
6
7 name 'pleiades-gm'
8 description 'Pleiades ganglia gmetad node'
9
10 run_list(
11   'role[node_commons]',
12   'role[nameservice-client-grid]',
13   'role[ganglia-gmond]',
14   'role[ganglia-gmetad]',
15   'role[ganglia-web]'
16 )
17
18 #env_run_lists "prod" => ["recipe[apache2]"], "staging" => ["recipe[apache2::staging]"], "_default" => []
19
20 this_subcluster = Grid::CLUSTERS[:pleiades][:gmetads]
21 mcast_addr = this_subcluster[:mcast_addr]
22 port = '8649'
23 polling_interval = '30'
24 =begin
25 # uni-cast
26 udp_send_channels4ucast = []
27 this_subcluster[:nodes].first(2).each {|host|
28   udp_send_channels4ucast.push(
29     {
30       'mcast_join' => '',
31       'host' => "#{host}.#{Grid::DOMAIN}",
32       'port' => port,
33       'ttl' => ''
34     }
35   )
36 }
37 =end
38
39 # for non-DataNodes
40 data_sources = []
41 Grid::CLUSTERS[:pleiades].select{|key| key != :datanodes}.each {|key, cluster|
42   data_sources.push(
43     {
44       :name => cluster[:alias],
45       :polling_interval => polling_interval,
46       # head nodes: 2
47       :address_list => cluster[:nodes].first(2).map{|host| "#{host}.#{Grid::DOMAIN}"}
48     }
49   )
50 }
51
52 # for DataNodes
53 head_node_nums = 2
54 digit_nums = 5
55 padstr = '0'
56 dn_data_sources = []
57 (0...2).step(40) {|v|
58 #(0...80).step(40) {|v|
59   first_head = v.to_s.rjust(digit_nums, padstr)
60   last_head = (v + head_node_nums -1).to_s.rjust(digit_nums, padstr)
61   dn_data_sources.push( 
62     {
63       :name => "DataNode#{first_head}",
64       :polling_interval => polling_interval,
65       :address_list => "dn{#{first_head}..#{last_head}}.#{Grid::DOMAIN}".expand
66     }
67   )
68 }
69
70 default_attributes(
71   'ganglia' => {
72     'web' => {
73       'Allow' => [
74         "from .#{Grid::DOMAIN}",
75         'from 192.168.0.0/16'],
76       'AuthType' => 'Kerberos',
77       'mod_auth_kerb' => {
78         'KrbAuthRealms' => Grid::REALM,
79         'Krb5Keytab' => '/etc/krb5.keytab'
80       }
81     }
82   },
83 )
84
85 override_attributes(
86   'ganglia' => {
87     # gmond
88     'cluster' => {
89       'name' => this_subcluster[:alias],
90       'owner' => Grid::DOMAIN
91     },
92     ## static multi-cast
93     'static' => {
94       'udp_send_channels' => [
95         {
96           'mcast_join' => mcast_addr,
97           'host' => '',
98           'port' => port,
99           'ttl' => '1'
100         }
101       ],
102       'udp_recv_channels' => [
103         {
104           'mcast_join' => mcast_addr,
105           'port' => port,
106           'bind' => mcast_addr
107         }
108       ],
109 =begin
110       ## static uni-cast
111       'udp_send_channels' => udp_send_channels4ucast,
112       'udp_recv_channels' => [
113         {
114           'mcast_join' => '',
115           'port' => port,
116           'bind' => ''
117         }
118       ],
119 =end
120     },
121     # gmetad
122     'gridname' => 'Pleiades',
123     'trusted_hosts' => ['127.0.0.1'] \
124       + Grid::CLUSTERS[:pleiades][:nagioses][:nodes].map{|host| "#{host}.#{Grid::DOMAIN}"},
125     'data_sources' => data_sources + dn_data_sources
126   }
127 )