OSDN Git Service

add zookeeper recipe.
authorwhitestar <whitestar@gaea.test>
Wed, 12 Jun 2013 07:00:45 +0000 (16:00 +0900)
committerwhitestar <whitestar@gaea.test>
Wed, 12 Jun 2013 07:00:45 +0000 (16:00 +0900)
22 files changed:
cookbooks/zookeeper/CHANGELOG.md [new file with mode: 0644]
cookbooks/zookeeper/README.md [new file with mode: 0644]
cookbooks/zookeeper/attributes/default.rb [new file with mode: 0644]
cookbooks/zookeeper/metadata.rb [new file with mode: 0644]
cookbooks/zookeeper/recipes/default.rb [new file with mode: 0644]
cookbooks/zookeeper/templates/default/conf/configuration.xsl [new file with mode: 0644]
cookbooks/zookeeper/templates/default/conf/jaas.conf [new file with mode: 0644]
cookbooks/zookeeper/templates/default/conf/java.env [new file with mode: 0644]
cookbooks/zookeeper/templates/default/conf/log4j.properties [new file with mode: 0644]
cookbooks/zookeeper/templates/default/conf/zoo.cfg [new file with mode: 0644]
cookbooks/zookeeper/templates/default/conf/zoo_sample.cfg [new file with mode: 0644]
cookbooks/zookeeper/templates/default/conf/zookeeper-env.sh [new file with mode: 0644]
nodes/localhost.json
nodes/mocker.json [moved from mocker.json with 100% similarity]
roles/yum_epel.rb
roles/zookeeper-colo00-with-security.rb [new file with mode: 0644]
roles/zookeeper-colo00.rb [new file with mode: 0644]
roles/zookeeper-pseudo-replicated-with-security.rb [new file with mode: 0644]
roles/zookeeper-pseudo-replicated.rb [new file with mode: 0644]
roles/zookeeper-standalone-with-security.rb [new file with mode: 0644]
roles/zookeeper-standalone.rb [new file with mode: 0644]
roles/zookeeper.rb [new file with mode: 0644]

diff --git a/cookbooks/zookeeper/CHANGELOG.md b/cookbooks/zookeeper/CHANGELOG.md
new file mode 100644 (file)
index 0000000..b6ff188
--- /dev/null
@@ -0,0 +1,12 @@
+# CHANGELOG for zookeeper
+
+This file is used to list changes made in each version of zookeeper.
+
+## 0.1.0:
+
+* Initial release of zookeeper
+
+- - -
+Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.
+
+The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.
diff --git a/cookbooks/zookeeper/README.md b/cookbooks/zookeeper/README.md
new file mode 100644 (file)
index 0000000..0d09496
--- /dev/null
@@ -0,0 +1,68 @@
+zookeeper Cookbook
+==================
+TODO: Enter the cookbook description here.
+
+e.g.
+This cookbook makes your favorite breakfast sandwhich.
+
+Requirements
+------------
+TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc.
+
+e.g.
+#### packages
+- `toaster` - zookeeper needs toaster to brown your bagel.
+
+Attributes
+----------
+TODO: List you cookbook attributes here.
+
+e.g.
+#### zookeeper::default
+<table>
+  <tr>
+    <th>Key</th>
+    <th>Type</th>
+    <th>Description</th>
+    <th>Default</th>
+  </tr>
+  <tr>
+    <td><tt>['zookeeper']['bacon']</tt></td>
+    <td>Boolean</td>
+    <td>whether to include bacon</td>
+    <td><tt>true</tt></td>
+  </tr>
+</table>
+
+Usage
+-----
+#### zookeeper::default
+TODO: Write usage instructions for each cookbook.
+
+e.g.
+Just include `zookeeper` in your node's `run_list`:
+
+```json
+{
+  "name":"my_node",
+  "run_list": [
+    "recipe[zookeeper]"
+  ]
+}
+```
+
+Contributing
+------------
+TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.
+
+e.g.
+1. Fork the repository on Github
+2. Create a named feature branch (like `add_component_x`)
+3. Write you change
+4. Write tests for your change (if applicable)
+5. Run the tests, ensuring they all pass
+6. Submit a Pull Request using Github
+
+License and Authors
+-------------------
+Authors: TODO: List authors
diff --git a/cookbooks/zookeeper/attributes/default.rb b/cookbooks/zookeeper/attributes/default.rb
new file mode 100644 (file)
index 0000000..43b55b2
--- /dev/null
@@ -0,0 +1,70 @@
+#
+# Cookbook Name:: zookeeper
+# Attributes:: default
+#
+# Copyright 2013, whitestar
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+default['grid']['etc_root'] = '/grid/etc'
+default['grid']['app_root'] = '/grid/usr'
+default['grid']['vol_root'] = '/grid/vol'
+default['grid']['max_vol_nums'] = '1'
+
+# default: for pseudo-replicated
+default['zookeeper']['install_flavor'] = 'apache'
+default['zookeeper']['version'] = '3.4.5'
+default['zookeeper']['archive_url'] = 'http://archive.apache.org/dist/zookeeper'
+default['zookeeper']['colo_name'] = 'localhost'
+## run mode: standalone, pseudo-replicated, full-replicated
+default['zookeeper']['run_mode'] = 'standalone'
+default['zookeeper']['with_security'] = false
+default['zookeeper']['realm'] = 'LOCALDOMAIN'
+default['zookeeper']['keytab_dir'] = "#{default['grid']['etc_root']}/keytabs/#{default['zookeeper']['colo_name']}"
+## zookeeper-env.sh
+default['zookeeper']['ZOO_LOG_DIR_PREFIX'] = "#{default['grid']['vol_root']}/0/var/log/zookeeper"
+## zoo.cfg
+default['zookeeper']['dataDirPrefix'] = "#{default['grid']['vol_root']}/0/var/lib/zookeeper"
+default['zookeeper']['clientPort'] = '2181'
+default['zookeeper']['ensemble'] = {
+}
+#default['zookeeper'][''] = 
+
+=begin
+# e.g. for pseudo-replicated
+default['zookeeper']['run_mode'] = 'pseudo-replicated'
+default['zookeeper']['clientPort'] = '2180'
+# e.g. for full-replicated 
+default['zookeeper']['run_mode'] = 'full-replicated'
+default['zookeeper']['colo_name'] = 'colo00'
+default['zookeeper']['realm'] = 'GRID.EXAMPLE.COM'
+default['zookeeper']['ensemble'] = {
+  '0' => {
+    :hostname => 'zk00.grid.example.com',
+    :leader_port => '2888',
+    :election_port => '3888'
+  },
+  '1' => {
+    :hostname => 'zk01.grid.example.com',
+    :leader_port => '2888',
+    :election_port => '3888'
+  },
+  '2' => {
+    :hostname => 'zk02.grid.example.com',
+    :leader_port => '2888',
+    :election_port => '3888'
+  }
+}
+=end
diff --git a/cookbooks/zookeeper/metadata.rb b/cookbooks/zookeeper/metadata.rb
new file mode 100644 (file)
index 0000000..f7411de
--- /dev/null
@@ -0,0 +1,7 @@
+name             'zookeeper'
+maintainer       'whitestar'
+maintainer_email ''
+license          'Apache 2.0'
+description      'Installs/Configures zookeeper'
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
+version          '0.1.0'
diff --git a/cookbooks/zookeeper/recipes/default.rb b/cookbooks/zookeeper/recipes/default.rb
new file mode 100644 (file)
index 0000000..30e7140
--- /dev/null
@@ -0,0 +1,255 @@
+#
+# Cookbook Name:: zookeeper
+# Recipe:: default
+#
+# Copyright 2013, whitestar
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+zookeeper_major_version = ''
+zookeeper_middle_version = ''
+
+if /^(\d+)\.(\d+)\.(\d+)$/ =~ node['zookeeper']['version'] then
+  zookeeper_major_version = $1
+  zookeeper_middle_version = "#{$1}.#{$2}"
+else
+  Chef::Application.fatal!("Invalid ZooKeeper version: #{node['zookeeper']['version']}")
+end
+
+users = {
+  :hadoop    => {:name => 'hadoop',    :uid => 10001},
+  :zookeeper => {:name => 'zookeeper', :uid => 10050}
+}
+
+def conf_template(conf_dir, conf_files, tpl_vars)
+  conf_files.each {|conf_file|
+    template "#{conf_dir}/#{conf_file}" do
+      source "conf/#{conf_file}"
+      #source "conf-#{zookeeper_middle_version}/#{conf_file}"
+      owner 'root'
+      group 'root'
+      mode '0644'
+      variables(tpl_vars)
+    end
+  }
+end
+
+users.each {|key, user|
+if key != :hadoop
+  group user[:name] do
+    gid user[:uid]
+    members []
+    action :create
+  end
+
+  user user[:name] do
+    uid user[:uid]
+    gid user[:uid]
+    home "/home/#{user[:name]}"
+    shell '/bin/sh'
+    password nil
+    supports :manage_home => false
+  end
+end
+}
+
+group users[:hadoop][:name] do
+  gid users[:hadoop][:uid]
+  members ['zookeeper']
+  append true
+  action :create
+end
+
+directory node['grid']['app_root'] do
+  owner 'root'
+  group 'root'
+  mode '0755'
+  action :create
+  recursive true
+end
+
+zookeeper_prefix = "#{node['grid']['app_root']}/zookeeper-#{node['zookeeper']['version']}"
+zookeeper_tarball = "zookeeper-#{node['zookeeper']['version']}.tar.gz"
+downloaded_zookeeper_tarball = "#{Chef::Config[:file_cache_path]}/#{zookeeper_tarball}"
+
+if ! FileTest.directory? zookeeper_prefix then
+  remote_file downloaded_zookeeper_tarball do
+    source "#{node['zookeeper']['archive_url']}/zookeeper-#{node['zookeeper']['version']}/#{zookeeper_tarball}"
+    action :create_if_missing
+  end
+
+  package 'tar' do
+    action :install
+  end
+
+  bash 'install_zookeeper' do
+    code <<-EOC
+      tar xvzf #{downloaded_zookeeper_tarball} -C #{node['grid']['app_root']}
+    EOC
+    creates zookeeper_prefix
+  end
+  
+  link "#{node['grid']['app_root']}/zookeeper" do
+    to zookeeper_prefix
+  end
+end
+
+conf_files = [
+  'configuration.xsl',
+  'jaas.conf',
+  'java.env',
+  'log4j.properties',
+  'zoo.cfg',
+  'zoo_sample.cfg',
+  'zookeeper-env.sh'
+]
+
+case node['zookeeper']['run_mode']
+  when 'standalone'
+    node_id = 'standalone'
+    conf_dir = "#{zookeeper_prefix}/conf.#{node_id}"
+    directory conf_dir do
+      owner 'root'
+      group 'root'
+      mode '0755'
+      action :create
+      recursive true
+    end
+    
+    %w{lib log}.each {|dir|
+      directory "#{node['grid']['vol_root']}/0/var/#{dir}/zookeeper/#{node_id}" do
+        owner 'zookeeper'
+        group 'zookeeper'
+        mode '0755'
+        action :create
+        recursive true
+      end
+    }
+
+    tpl_vars = {
+      :node_id => node_id,
+      :conf_dir => conf_dir,
+      :clientPort => node['zookeeper']['clientPort']
+    }
+    conf_template(conf_dir, conf_files, tpl_vars)
+
+    log <<-EOM
+Note:
+Start command:
+  $ cd $ZOOKEEPER_PREFIX
+  $ sudo -u zookeeper sh -c 'export ZOOCFGDIR=/grid/usr/zookeeper/conf.standalone;./bin/zkServer.sh start'
+    EOM
+  when 'pseudo-replicated'
+    clientPort = node['zookeeper']['clientPort'].to_i
+    3.times {|node_id|
+      conf_dir = "#{zookeeper_prefix}/conf.#{node_id}"
+      directory conf_dir do
+        owner 'root'
+        group 'root'
+        mode '0755'
+        action :create
+        recursive true
+      end
+    
+      %w{lib log}.each {|dir|
+        directory "#{node['grid']['vol_root']}/0/var/#{dir}/zookeeper/#{node_id}" do
+          owner 'zookeeper'
+          group 'zookeeper'
+          mode '0755'
+          action :create
+          recursive true
+        end
+      }
+      
+      myid_file = "#{node['grid']['vol_root']}/0/var/lib/zookeeper/#{node_id}/myid"
+      bash "setup_myid_#{node_id}" do
+        code <<-EOC
+          echo #{node_id} > #{myid_file}
+        EOC
+        creates myid_file
+      end
+
+      tpl_vars = {
+        :node_id => node_id,
+        :conf_dir => conf_dir,
+        :clientPort => clientPort
+      }
+      conf_template(conf_dir, conf_files, tpl_vars)
+      
+      clientPort = clientPort + 1
+    }
+
+    log <<-EOM
+Note:
+Start command:
+  $ cd $ZOOKEEPER_PREFIX
+  $ sudo -u zookeeper sh -c 'export ZOOCFGDIR=/grid/usr/zookeeper/conf.0;./bin/zkServer.sh start'
+  $ sudo -u zookeeper sh -c 'export ZOOCFGDIR=/grid/usr/zookeeper/conf.1;./bin/zkServer.sh start'
+  $ sudo -u zookeeper sh -c 'export ZOOCFGDIR=/grid/usr/zookeeper/conf.2;./bin/zkServer.sh start'
+    EOM
+  when 'full-replicated'
+    conf_dir = "#{zookeeper_prefix}/conf"
+    %w{lib log}.each {|dir|
+      directory "#{node['grid']['vol_root']}/0/var/#{dir}/zookeeper" do
+        owner 'zookeeper'
+        group 'zookeeper'
+        mode '0755'
+        action :create
+        recursive true
+      end
+    }
+    
+    tpl_vars = {
+      :node_id => '',
+      :conf_dir => conf_dir,
+      :clientPort => node['zookeeper']['clientPort']
+    }
+    conf_template(conf_dir, conf_files, tpl_vars)
+
+    node_id = ''
+    node['zookeeper']['ensemble'].each {|id, server|
+      if server[:hostname] == node[:fqdn] then
+        node_id = id
+        break
+      end
+    }
+    myid_file = "#{node['grid']['vol_root']}/0/var/lib/zookeeper/myid"
+    bash "setup_myid_#{node_id}" do
+      code <<-EOC
+        echo #{node_id} > #{myid_file}
+      EOC
+      creates myid_file
+    end
+
+    log <<-EOM
+Note:
+Start command:
+  $ cd $ZOOKEEPER_PREFIX
+  $ sudo -u zookeeper ./bin/zkServer.sh start
+    EOM
+end
+
+# with security
+if node['zookeeper']['with_security'] then
+
+directory node['zookeeper']['keytab_dir'] do
+  owner 'root'
+  group 'root'
+  mode '0755'
+  action :create
+  recursive true
+end
+
+end
+
diff --git a/cookbooks/zookeeper/templates/default/conf/configuration.xsl b/cookbooks/zookeeper/templates/default/conf/configuration.xsl
new file mode 100644 (file)
index 0000000..377cdbe
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:output method="html"/>
+<xsl:template match="configuration">
+<html>
+<body>
+<table border="1">
+<tr>
+ <td>name</td>
+ <td>value</td>
+ <td>description</td>
+</tr>
+<xsl:for-each select="property">
+<tr>
+  <td><a name="{name}"><xsl:value-of select="name"/></a></td>
+  <td><xsl:value-of select="value"/></td>
+  <td><xsl:value-of select="description"/></td>
+</tr>
+</xsl:for-each>
+</table>
+</body>
+</html>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/cookbooks/zookeeper/templates/default/conf/jaas.conf b/cookbooks/zookeeper/templates/default/conf/jaas.conf
new file mode 100644 (file)
index 0000000..5aba56b
--- /dev/null
@@ -0,0 +1,25 @@
+Server {
+    com.sun.security.auth.module.Krb5LoginModule required
+        useKeyTab=true
+        keyTab="<%= node['zookeeper']['keytab_dir'] %>/zk.keytab"
+        storeKey=true
+        useTicketCache=false
+<%
+case node['zookeeper']['run_mode']
+  when 'standalone', 'pseudo-replicated'
+%>
+        principal="zookeeper/localhost@<%= node['zookeeper']['realm'] %>";
+<%
+  when 'full-replicated'
+%>
+        principal="zookeeper/${this.fqdn}@<%= node['zookeeper']['realm'] %>";
+<%
+end
+%>
+};
+Client {
+    com.sun.security.auth.module.Krb5LoginModule required
+        useKeyTab=false
+        useTicketCache=true
+        debug=true;
+};
diff --git a/cookbooks/zookeeper/templates/default/conf/java.env b/cookbooks/zookeeper/templates/default/conf/java.env
new file mode 100644 (file)
index 0000000..0c66086
--- /dev/null
@@ -0,0 +1,5 @@
+<% if node['zookeeper']['with_security'] then %>
+FQDN=`hostname --fqdn`
+
+export JVMFLAGS="-Dthis.fqdn=${FQDN} -Djava.security.auth.login.config=<%= @conf_dir %>/jaas.conf"
+<% end %>
diff --git a/cookbooks/zookeeper/templates/default/conf/log4j.properties b/cookbooks/zookeeper/templates/default/conf/log4j.properties
new file mode 100644 (file)
index 0000000..9825970
--- /dev/null
@@ -0,0 +1,58 @@
+# Define some default values that can be overridden by system properties
+zookeeper.root.logger=INFO, CONSOLE
+zookeeper.console.threshold=INFO
+zookeeper.log.dir=.
+zookeeper.log.file=zookeeper.log
+zookeeper.log.threshold=DEBUG
+zookeeper.tracelog.dir=.
+zookeeper.tracelog.file=zookeeper_trace.log
+
+#
+# ZooKeeper Logging Configuration
+#
+
+# Format is "<default threshold> (, <appender>)+
+
+# DEFAULT: console appender only
+log4j.rootLogger=${zookeeper.root.logger}
+
+# Example with rolling log file
+#log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE
+
+# Example with rolling log file and tracing
+#log4j.rootLogger=TRACE, CONSOLE, ROLLINGFILE, TRACEFILE
+
+#
+# Log INFO level and above messages to the console
+#
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Threshold=${zookeeper.console.threshold}
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n
+
+#
+# Add ROLLINGFILE to rootLogger to get log file output
+#    Log DEBUG level and above messages to a log file
+log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender
+log4j.appender.ROLLINGFILE.Threshold=${zookeeper.log.threshold}
+log4j.appender.ROLLINGFILE.File=${zookeeper.log.dir}/${zookeeper.log.file}
+
+# Max log file size of 10MB
+log4j.appender.ROLLINGFILE.MaxFileSize=10MB
+# uncomment the next line to limit number of backup files
+#log4j.appender.ROLLINGFILE.MaxBackupIndex=10
+
+log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout
+log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n
+
+
+#
+# Add TRACEFILE to rootLogger to get log file output
+#    Log DEBUG level and above messages to a log file
+log4j.appender.TRACEFILE=org.apache.log4j.FileAppender
+log4j.appender.TRACEFILE.Threshold=TRACE
+log4j.appender.TRACEFILE.File=${zookeeper.tracelog.dir}/${zookeeper.tracelog.file}
+
+log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout
+### Notice we are including log4j's NDC here (%x)
+log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L][%x] - %m%n
diff --git a/cookbooks/zookeeper/templates/default/conf/zoo.cfg b/cookbooks/zookeeper/templates/default/conf/zoo.cfg
new file mode 100644 (file)
index 0000000..b8d5cdd
--- /dev/null
@@ -0,0 +1,55 @@
+# The number of milliseconds of each tick
+tickTime=2000
+# The number of ticks that the initial 
+# synchronization phase can take
+initLimit=10
+# The number of ticks that can pass between 
+# sending a request and getting an acknowledgement
+syncLimit=5
+# the directory where the snapshot is stored.
+# do not use /tmp for storage, /tmp here is just 
+# example sakes.
+#dataDir=/tmp/zookeeper
+dataDir=<%= node['zookeeper']['dataDirPrefix'] %><%= @node_id == '' ? '' : "/#{@node_id}"%>
+#dataLogDir=/grid/vol/1/var/lib/zookeeper
+# the port at which the clients will connect
+clientPort=<%= @clientPort %>
+<% if node['zookeeper']['with_security'] then %>
+authProvider.0=org.apache.zookeeper.server.auth.SASLAuthenticationProvider
+jaasLoginRenew=3600000
+kerberos.removeHostFromPrincipal=true
+kerberos.removeRealmFromPrincipal=true
+# available?!
+#requireClientAuthScheme=sasl
+#allowSaslFailedClients=false
+#maintain_connection_despite_sasl_failure=false
+<% end %>
+#
+# Be sure to read the maintenance section of the 
+# administrator guide before turning on autopurge.
+#
+# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
+#
+# The number of snapshots to retain in dataDir
+#autopurge.snapRetainCount=3
+# Purge task interval in hours
+# Set to "0" to disable auto purge feature
+#autopurge.purgeInterval=1
+
+<%
+case node['zookeeper']['run_mode']
+  when 'pseudo-replicated'
+%>
+# Pseudo ensemble mode on single host
+server.0=localhost:2888:3888
+server.1=localhost:2889:3889
+server.2=localhost:2890:3890
+<%
+  when 'full-replicated'
+    node['zookeeper']['ensemble'].each do |id, server|
+%>
+server.<%= id %>=<%= server[:hostname] %>:<%= server[:leader_port] %>:<%= server[:election_port] %>
+<%
+    end
+end
+%>
diff --git a/cookbooks/zookeeper/templates/default/conf/zoo_sample.cfg b/cookbooks/zookeeper/templates/default/conf/zoo_sample.cfg
new file mode 100644 (file)
index 0000000..aafb324
--- /dev/null
@@ -0,0 +1,25 @@
+# The number of milliseconds of each tick
+tickTime=2000
+# The number of ticks that the initial 
+# synchronization phase can take
+initLimit=10
+# The number of ticks that can pass between 
+# sending a request and getting an acknowledgement
+syncLimit=5
+# the directory where the snapshot is stored.
+# do not use /tmp for storage, /tmp here is just 
+# example sakes.
+dataDir=/tmp/zookeeper
+# the port at which the clients will connect
+clientPort=2181
+#
+# Be sure to read the maintenance section of the 
+# administrator guide before turning on autopurge.
+#
+# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
+#
+# The number of snapshots to retain in dataDir
+#autopurge.snapRetainCount=3
+# Purge task interval in hours
+# Set to "0" to disable auto purge feature
+#autopurge.purgeInterval=1
diff --git a/cookbooks/zookeeper/templates/default/conf/zookeeper-env.sh b/cookbooks/zookeeper/templates/default/conf/zookeeper-env.sh
new file mode 100644 (file)
index 0000000..69f3c58
--- /dev/null
@@ -0,0 +1,3 @@
+export JAVA_HOME=<%= node['java']['java_home'] %>
+
+export ZOO_LOG_DIR=<%= node['zookeeper']['ZOO_LOG_DIR_PREFIX'] %><%= @node_id == '' ? '' : "/#{@node_id}"%>
index f8160e3..a26a993 100644 (file)
@@ -1,6 +1,7 @@
 {
   "run_list": [
     "role[mocker]",
-    "role[hadoop-pseudo-distributed-with-security]"
+    "role[hadoop-pseudo-distributed-with-security]",
+    "role[zookeeper-pseudo-replicated-with-security]"
   ]
 }
similarity index 100%
rename from mocker.json
rename to nodes/mocker.json
index 2575fed..b7a04d3 100644 (file)
@@ -1,5 +1,5 @@
 name 'yum_epel'
-description 'Extra Packages for Enterprise Linux. thie role does nothing in platforms other than RHEL.'
+description 'Extra Packages for Enterprise Linux. this role does nothing in other platforms than RHEL.'
 
 run_list(
   'recipe[yum]',
diff --git a/roles/zookeeper-colo00-with-security.rb b/roles/zookeeper-colo00-with-security.rb
new file mode 100644 (file)
index 0000000..4155652
--- /dev/null
@@ -0,0 +1,19 @@
+name 'zookeeper-colo00-with-security'
+description 'ZooKeeper colo00 node with security'
+
+run_list(
+  'role[nameservice-client-grid]',
+  'role[zookeeper-colo00]',
+  'role[jce_policy]'
+)
+
+#env_run_lists "prod" => ["recipe[apache2]"], "staging" => ["recipe[apache2::staging]"], "_default" => []
+
+default_attributes(
+  'zookeeper' => {
+    'with_security' => true,
+    'realm' => 'GRID.EXAMPLE.COM'
+  }
+)
+
+#override_attributes "apache2" => { "max_children" => "50" }
diff --git a/roles/zookeeper-colo00.rb b/roles/zookeeper-colo00.rb
new file mode 100644 (file)
index 0000000..db91ef9
--- /dev/null
@@ -0,0 +1,36 @@
+name 'zookeeper-colo00'
+description 'ZooKeeper colo00 node'
+
+run_list(
+  'role[zookeeper]'
+)
+
+#env_run_lists "prod" => ["recipe[apache2]"], "staging" => ["recipe[apache2::staging]"], "_default" => []
+
+ensemble = {
+  '0' => {
+    :hostname => 'zk00.grid.example.com',
+    :leader_port => '2888',
+    :election_port => '3888'
+  },
+  '1' => {
+    :hostname => 'zk01.grid.example.com',
+    :leader_port => '2888',
+    :election_port => '3888'
+  },
+  '2' => {
+    :hostname => 'zk02.grid.example.com',
+    :leader_port => '2888',
+    :election_port => '3888'
+  }
+}
+
+default_attributes(
+  'zookeeper' => {
+    'run_mode' => 'full-replicated',
+    'colo_name' => 'colo00',
+    'ensemble' => ensemble
+  }
+)
+
+#override_attributes "apache2" => { "max_children" => "50" }
diff --git a/roles/zookeeper-pseudo-replicated-with-security.rb b/roles/zookeeper-pseudo-replicated-with-security.rb
new file mode 100644 (file)
index 0000000..c5abdf8
--- /dev/null
@@ -0,0 +1,18 @@
+name 'zookeeper-pseudo-replicated-with-security'
+description 'ZooKeeper pseudo replicated mode with security'
+
+run_list(
+  'role[nameservice-master]',
+  'role[zookeeper-pseudo-replicated]',
+  'role[jce_policy]'
+)
+
+#env_run_lists "prod" => ["recipe[apache2]"], "staging" => ["recipe[apache2::staging]"], "_default" => []
+
+default_attributes(
+  'zookeeper' => {
+    'with_security' => true
+  }
+)
+
+#override_attributes "apache2" => { "max_children" => "50" }
diff --git a/roles/zookeeper-pseudo-replicated.rb b/roles/zookeeper-pseudo-replicated.rb
new file mode 100644 (file)
index 0000000..9751309
--- /dev/null
@@ -0,0 +1,17 @@
+name 'zookeeper-pseudo-replicated'
+description 'ZooKeeper pseudo replicated mode'
+
+run_list(
+  'role[zookeeper]'
+)
+
+#env_run_lists "prod" => ["recipe[apache2]"], "staging" => ["recipe[apache2::staging]"], "_default" => []
+
+default_attributes(
+  'zookeeper' => {
+    'run_mode' => 'pseudo-replicated',
+    'clientPort' => '2180'
+  }
+)
+
+#override_attributes "apache2" => { "max_children" => "50" }
diff --git a/roles/zookeeper-standalone-with-security.rb b/roles/zookeeper-standalone-with-security.rb
new file mode 100644 (file)
index 0000000..fca0885
--- /dev/null
@@ -0,0 +1,18 @@
+name 'zookeeper-standalone-with-security'
+description 'ZooKeeper standalone mode with security'
+
+run_list(
+  'role[nameservice-master]',
+  'role[zookeeper-standalone]',
+  'role[jce_policy]'
+)
+
+#env_run_lists "prod" => ["recipe[apache2]"], "staging" => ["recipe[apache2::staging]"], "_default" => []
+
+default_attributes(
+  'zookeeper' => {
+    'with_security' => true
+  }
+)
+
+#override_attributes "apache2" => { "max_children" => "50" }
diff --git a/roles/zookeeper-standalone.rb b/roles/zookeeper-standalone.rb
new file mode 100644 (file)
index 0000000..ab13d37
--- /dev/null
@@ -0,0 +1,16 @@
+name 'zookeeper-standalone'
+description 'ZooKeeper standalone mode'
+
+run_list(
+  'role[zookeeper]'
+)
+
+#env_run_lists "prod" => ["recipe[apache2]"], "staging" => ["recipe[apache2::staging]"], "_default" => []
+
+default_attributes(
+  'zookeeper' => {
+    'run_mode' => 'standalone'
+  }
+)
+
+#override_attributes "apache2" => { "max_children" => "50" }
diff --git a/roles/zookeeper.rb b/roles/zookeeper.rb
new file mode 100644 (file)
index 0000000..9d4ca0b
--- /dev/null
@@ -0,0 +1,12 @@
+name 'zookeeper'
+description 'ZooKeeper node'
+
+run_list(
+  #'recipe[yum]',
+  'role[java]',
+  'recipe[zookeeper]'
+)
+
+#env_run_lists "prod" => ["recipe[apache2]"], "staging" => ["recipe[apache2::staging]"], "_default" => []
+#default_attributes "apache2" => { "listen_ports" => [ "80", "443" ] }
+#override_attributes "apache2" => { "max_children" => "50" }