OSDN Git Service

fix service control.
[metasearch/grid-chef-repo.git] / roles / grid-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 name 'grid-gm'
24 description 'Grid Base ganglia gmetad node'
25
26 run_list(
27   'role[node_commons]',
28   'role[nameservice-client-grid]',
29   'role[ganglia-gmond]',
30   'role[ganglia-gmetad]',
31   'role[ganglia-web]'
32 )
33
34 this_subcluster = Grid::CLUSTERS[:base][:gmetads]
35 mcast_addr = this_subcluster[:mcast_addr]
36 port = '8649'
37 polling_interval = 30
38 =begin
39 # uni-cast
40 udp_send_channels4ucast = []
41 this_subcluster[:nodes].first(2).each {|host|
42   udp_send_channels4ucast.push(
43     {
44       'mcast_join' => '',
45       'host' => "#{host}.#{Grid::DOMAIN}",
46       'port' => port,
47       'ttl' => ''
48     }
49   )
50 }
51 =end
52
53 data_sources = []
54 Grid::CLUSTERS[:base].each {|key, cluster|
55   data_sources.push(
56     {
57       :name => cluster[:alias],
58       :polling_interval => polling_interval,
59       # head nodes: 2
60       :address_list => cluster[:nodes].first(2).map{|host| "#{host}.#{Grid::DOMAIN}"}
61     }
62   )
63 }
64
65 #env_run_lists "prod" => ["recipe[apache2]"], "staging" => ["recipe[apache2::staging]"], "_default" => []
66
67 default_attributes(
68   'ganglia' => {
69     'web' => {
70       'Allow' => [
71         "from .#{Grid::DOMAIN}",
72         'from 192.168.0.0/16'],
73       'AuthType' => 'Kerberos',
74       'mod_auth_kerb' => {
75         'KrbAuthRealms' => Grid::REALM,
76         'Krb5Keytab' => '/etc/krb5.keytab'
77       }
78     }
79   },
80 )
81
82 override_attributes(
83   'ganglia' => {
84     # gmond
85     'cluster' => {
86       'name' => this_subcluster[:alias],
87       'owner' => Grid::DOMAIN
88     },
89     ## static multi-cast
90     'static' => {
91       'udp_send_channels' => [
92         {
93           'mcast_join' => mcast_addr,
94           'host' => '',
95           'port' => port,
96           'ttl' => '1'
97         }
98       ],
99       'udp_recv_channels' => [
100         {
101           'mcast_join' => mcast_addr,
102           'port' => port,
103           'bind' => mcast_addr
104         }
105       ]
106 =begin
107       ## static uni-cast
108       'udp_send_channels' => udp_send_channels4ucast,
109       'udp_recv_channels' => [
110         {
111           'mcast_join' => '',
112           'port' => port,
113           'bind' => ''
114         }
115       ]
116 =end
117     },
118     # gmetad
119     'gridname' => 'Grid-Base',
120     'trusted_hosts' => ['127.0.0.1'] \
121       + Grid::CLUSTERS[:base][:nagioses][:nodes].map{|host| "#{host}.#{Grid::DOMAIN}"},
122     'data_sources' => data_sources
123   }
124 )