OSDN Git Service

add apache_utils cookbook.
authorwhitestar <whitestar@gaea.test>
Sat, 28 Sep 2013 02:17:41 +0000 (11:17 +0900)
committerwhitestar <whitestar@gaea.test>
Sat, 28 Sep 2013 02:17:41 +0000 (11:17 +0900)
40 files changed:
cookbooks/apache_utils/CHANGELOG.md [new file with mode: 0644]
cookbooks/apache_utils/README.md [new file with mode: 0644]
cookbooks/apache_utils/attributes/default.rb [new file with mode: 0644]
cookbooks/apache_utils/metadata.rb [new file with mode: 0644]
cookbooks/apache_utils/recipes/default.rb [new file with mode: 0644]
cookbooks/apache_utils/recipes/mirror.rb [new file with mode: 0644]
cookbooks/apache_utils/templates/default/etc/apache2/conf.d/apache-mirror [new file with mode: 0644]
cookbooks/apache_utils/templates/default/etc/cron.d/apache-mirror [new file with mode: 0644]
cookbooks/apache_utils/templates/default/usr/local/bin/apache-mirror [new file with mode: 0644]
cookbooks/apache_utils/templates/default/usr/local/bin/yum-mirror [new file with mode: 0644]
cookbooks/apt_utils/attributes/default.rb
cookbooks/apt_utils/metadata.rb
cookbooks/apt_utils/recipes/mirror.rb
cookbooks/apt_utils/templates/default/etc/cron.d/apt-mirror
cookbooks/cdh/attributes/default.rb
cookbooks/cdh/recipes/yum_repo.rb
cookbooks/commons/CHANGELOG.md [new file with mode: 0644]
cookbooks/commons/README.md [new file with mode: 0644]
cookbooks/commons/libraries/package_utils.rb [new file with mode: 0644]
cookbooks/commons/metadata.rb [new file with mode: 0644]
cookbooks/commons/recipes/default.rb [new file with mode: 0644]
cookbooks/hadoop/libraries/helper.rb
cookbooks/hadoop/metadata.rb
cookbooks/hadoop/recipes/apache.rb
cookbooks/hadoop/recipes/build.rb
cookbooks/hadoop/recipes/cdh.rb
cookbooks/hadoop/recipes/hdp.rb
cookbooks/hadoop/recipes/lzo-build.rb
cookbooks/yum_utils/attributes/default.rb
cookbooks/yum_utils/metadata.rb
cookbooks/yum_utils/recipes/mirror.rb
cookbooks/yum_utils/recipes/repos.rb [new file with mode: 0644]
cookbooks/yum_utils/templates/default/etc/cron.d/yum-mirror
cookbooks/yum_utils/templates/default/etc/yum.repos.d/CentOS-Base.repo [new file with mode: 0644]
cookbooks/yum_utils/templates/default/etc/yum.repos.d/epel.repo [new file with mode: 0644]
cookbooks/yum_utils/templates/default/usr/local/bin/yum-mirror
nodes/localhost-apache-mirror.json [new file with mode: 0644]
roles/apache-mirror.rb [new file with mode: 0644]
roles/grid-ftp.rb
roles/yum-repos.rb [new file with mode: 0644]

diff --git a/cookbooks/apache_utils/CHANGELOG.md b/cookbooks/apache_utils/CHANGELOG.md
new file mode 100644 (file)
index 0000000..f1ae7f1
--- /dev/null
@@ -0,0 +1,13 @@
+apache_utils CHANGELOG
+======================
+
+This file is used to list changes made in each version of the apache_utils cookbook.
+
+0.1.0
+-----
+- [your_name] - Initial release of apache_utils
+
+- - -
+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/apache_utils/README.md b/cookbooks/apache_utils/README.md
new file mode 100644 (file)
index 0000000..3500ff5
--- /dev/null
@@ -0,0 +1,68 @@
+apache_utils 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` - apache_utils needs toaster to brown your bagel.
+
+Attributes
+----------
+TODO: List you cookbook attributes here.
+
+e.g.
+#### apache_utils::default
+<table>
+  <tr>
+    <th>Key</th>
+    <th>Type</th>
+    <th>Description</th>
+    <th>Default</th>
+  </tr>
+  <tr>
+    <td><tt>['apache_utils']['bacon']</tt></td>
+    <td>Boolean</td>
+    <td>whether to include bacon</td>
+    <td><tt>true</tt></td>
+  </tr>
+</table>
+
+Usage
+-----
+#### apache_utils::default
+TODO: Write usage instructions for each cookbook.
+
+e.g.
+Just include `apache_utils` in your node's `run_list`:
+
+```json
+{
+  "name":"my_node",
+  "run_list": [
+    "recipe[apache_utils]"
+  ]
+}
+```
+
+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/apache_utils/attributes/default.rb b/cookbooks/apache_utils/attributes/default.rb
new file mode 100644 (file)
index 0000000..676fabb
--- /dev/null
@@ -0,0 +1,33 @@
+#
+# Cookbook Name:: apache_utils
+# 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['apache_utils']['mirror']['user'] = 'apache-mirror'
+default['apache_utils']['mirror']['cron_period'] = '#0 2       * * *'  # default: inactive
+default['apache_utils']['mirror']['base_path'] = '/var/spool/apache-mirror'
+default['apache_utils']['mirror']['rsync_sources'] = [
+  # Apache
+  # http://www.apache.org/info/how-to-mirror.html
+  {
+    'url' => 'rsync.apache.org::apache-dist',
+    #'url' => 'rsync.apache.org::apache-dist-most',
+    'rsync_opts' => '-avSH --stats --partial --delete --safe-links',
+    'http_alias' => '/apache'
+  }
+]
+
diff --git a/cookbooks/apache_utils/metadata.rb b/cookbooks/apache_utils/metadata.rb
new file mode 100644 (file)
index 0000000..9d57cce
--- /dev/null
@@ -0,0 +1,9 @@
+name             'apache_utils'
+maintainer       'whitestar'
+maintainer_email ''
+license          'Apache 2.0'
+description      'Installs/Configures apache_utils'
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
+version          '0.1.0'
+
+depends  'commons'
diff --git a/cookbooks/apache_utils/recipes/default.rb b/cookbooks/apache_utils/recipes/default.rb
new file mode 100644 (file)
index 0000000..5fc68b7
--- /dev/null
@@ -0,0 +1,18 @@
+#
+# Cookbook Name:: apache_utils
+# 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.
+#
diff --git a/cookbooks/apache_utils/recipes/mirror.rb b/cookbooks/apache_utils/recipes/mirror.rb
new file mode 100644 (file)
index 0000000..254a979
--- /dev/null
@@ -0,0 +1,130 @@
+#
+# Cookbook Name:: apache_utils
+# Recipe:: mirror
+#
+# 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.
+#
+
+::Chef::Recipe.send(:include, Commons::PackageUtils)
+
+mirror_user = node['apache_utils']['mirror']['user']
+base_path = node['apache_utils']['mirror']['base_path']
+
+resources(:group => mirror_user) rescue group mirror_user do
+  system true
+  action :create
+end
+
+resources(:user => mirror_user) rescue user mirror_user do
+  gid mirror_user
+  system true
+  home base_path
+  shell '/bin/sh'
+  password nil
+  action :create
+end
+
+httpd_service = get_httpd_pkg_name
+
+case node[:platform_family]
+when 'debian'
+  httpd_conf_path = "/etc/#{httpd_service}/conf.d/apache-mirror"
+when 'rhel'
+  httpd_conf_path = "/etc/#{httpd_service}/conf.d/apache-mirror.conf"
+end
+
+pkg = 'rsync'
+resources(:package => pkg) rescue package pkg do
+  action :install
+end
+
+pkg = get_cron_pkg_name
+resources(:package => pkg) rescue package pkg do
+  action :install
+end
+
+[
+  '',
+  'mirror',
+  'var'
+].each {|subdir|
+  directory "#{base_path}/#{subdir}" do
+    owner mirror_user
+    group mirror_user
+    mode '0755'
+    recursive true
+  end
+}
+
+rsync_sources = []
+node['apache_utils']['mirror']['rsync_sources'].each {|source|
+  local_path = "#{base_path}/mirror/#{source['url'].gsub(/^rsync:\/\//, '').gsub(/:.*$/, '')}"
+  if local_path.end_with?('/') then
+    local_path.chop!
+  end
+  directory local_path do
+    owner mirror_user
+    group mirror_user
+    mode '0755'
+    recursive true
+  end
+
+  rsync_sources.push(
+    {
+      'http_alias' => source['http_alias'],
+      'local_path' => local_path,
+      'rsync_command' => "rsync #{source['rsync_opts']} #{source['url']} #{local_path}/",
+    }
+  )
+}
+
+template '/usr/local/bin/apache-mirror' do
+  source 'usr/local/bin/apache-mirror'
+  owner 'root'
+  group 'root'
+  mode '0755'
+  variables({
+    :rsync_sources => rsync_sources
+  })
+end
+
+template '/etc/cron.d/apache-mirror' do
+  source 'etc/cron.d/apache-mirror'
+  owner 'root'
+  group 'root'
+  mode '0644'
+end
+
+pkg = httpd_service
+resources(:package => pkg) rescue package pkg do
+  action :install
+end
+
+resources(:service => httpd_service) rescue service httpd_service do
+  action [:enable, :start]
+  supports :status => true, :restart => true, :reload => true
+end
+
+template httpd_conf_path do
+  source 'etc/apache2/conf.d/apache-mirror'
+  owner 'root'
+  group 'root'
+  mode '0644'
+  variables({
+    :rsync_sources => rsync_sources
+  })
+  notifies :restart, "service[#{httpd_service}]"
+end
+
diff --git a/cookbooks/apache_utils/templates/default/etc/apache2/conf.d/apache-mirror b/cookbooks/apache_utils/templates/default/etc/apache2/conf.d/apache-mirror
new file mode 100644 (file)
index 0000000..ea86a60
--- /dev/null
@@ -0,0 +1,36 @@
+#
+# 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.
+#
+
+<%
+@rsync_sources.each do |source|
+-%>
+Alias <%= source['http_alias'] %> <%= source['local_path'] %> 
+<Directory <%= source['local_path'] %>>
+  Options Indexes SymLinksIfOwnerMatch FollowSymLinks
+  IndexOptions FancyIndexing NameWidth=* FoldersFirst ScanHTMLTitles DescriptionWidth=*
+  #IndexOptions NameWidth=* +SuppressDescription
+  HeaderName HEADER.html
+  ReadmeName README.html
+  AllowOverride FileInfo Indexes
+  Order Deny,Allow
+  Allow from all
+  ErrorDocument 404 default
+</Directory>
+
+<%
+end
+-%>
+
diff --git a/cookbooks/apache_utils/templates/default/etc/cron.d/apache-mirror b/cookbooks/apache_utils/templates/default/etc/cron.d/apache-mirror
new file mode 100644 (file)
index 0000000..98f265f
--- /dev/null
@@ -0,0 +1,19 @@
+#
+# Regular cron jobs for the apache-mirror
+#
+# 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.
+#
+
+<%= node['apache_utils']['mirror']['cron_period'] %>   <%= node['apache_utils']['mirror']['user'] %>   /usr/local/bin/apache-mirror > <%= node['apache_utils']['mirror']['base_path'] %>/var/cron.log
diff --git a/cookbooks/apache_utils/templates/default/usr/local/bin/apache-mirror b/cookbooks/apache_utils/templates/default/usr/local/bin/apache-mirror
new file mode 100644 (file)
index 0000000..62e1e92
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh
+#
+# 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.
+#
+
+<%
+@rsync_sources.each do |source|
+-%>
+echo -n 'Begin time: '; date
+<%= source['rsync_command'] %>
+echo -n 'End time: '; date
+
+<%
+end
+-%>
+
diff --git a/cookbooks/apache_utils/templates/default/usr/local/bin/yum-mirror b/cookbooks/apache_utils/templates/default/usr/local/bin/yum-mirror
new file mode 100644 (file)
index 0000000..62e1e92
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh
+#
+# 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.
+#
+
+<%
+@rsync_sources.each do |source|
+-%>
+echo -n 'Begin time: '; date
+<%= source['rsync_command'] %>
+echo -n 'End time: '; date
+
+<%
+end
+-%>
+
index 33e85fd..5fe2c29 100644 (file)
@@ -21,6 +21,7 @@ default['apt_utils']['source']['apt_lines'] = [
   'deb http://cdn.debian.net/debian wheezy main'
 ]
 
+default['apt_utils']['mirror']['user'] = 'apt-mirror'
 default['apt_utils']['mirror']['cron_period'] = '#0 4  * * *'  # default: inactive
 default['apt_utils']['mirror']['base_path'] = '/var/spool/apt-mirror'
 default['apt_utils']['mirror']['nthreads'] = '20'
@@ -29,10 +30,11 @@ default['apt_utils']['mirror']['country'] = 'us'  # or jp,...
 # http://www.debian.org/mirror/official
 # https://launchpad.net/ubuntu/+archivemirrors
 default['apt_utils']['mirror']['distributions']['debian'] = {
+  # default: empty (inactive)
   'code_names' => [
-    'wheezy',
-    'wheezy-updates',
-    'wheezy-backports',
+    #'wheezy',
+    #'wheezy-updates',
+    #'wheezy-backports',
     #'squeeze'
   ],
   'architectures' => [
@@ -47,7 +49,7 @@ default['apt_utils']['mirror']['distributions']['debian'] = {
   ]
 }
 default['apt_utils']['mirror']['distribution']['ubuntu'] = {
-  # default: empty
+  # default: empty (inactive)
   'code_names' => [
     #'raring',
     #'raring-updates',
index 8f8c2b6..fb9683a 100644 (file)
@@ -5,3 +5,5 @@ license          'Apache 2.0'
 description      'Installs/Configures apt_utils'
 long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
 version          '0.1.0'
+
+depends  'commons'
index 7c9d988..a6232b9 100644 (file)
 # limitations under the License.
 #
 
+::Chef::Recipe.send(:include, Commons::PackageUtils)
+
 pkg = 'apt-mirror'  # CentOS: in the EPEL
 resources(:package => pkg) rescue package pkg do
   action :install
 end
 
+mirror_user = node['apt_utils']['mirror']['user']
+base_path = node['apt_utils']['mirror']['base_path']
+
+resources(:group => mirror_user) rescue group mirror_user do
+  system true
+  action :create
+end
+
+resources(:user => mirror_user) rescue user mirror_user do
+  gid mirror_user
+  system true
+  home base_path
+  shell '/bin/sh'
+  password nil
+  action :create
+end
+
+bash "#{base_path} - change owner to #{mirror_user}:#{mirror_user} recursively." do
+  code <<-EOC
+    chown -R #{mirror_user}:#{mirror_user} #{base_path}
+  EOC
+end
+
 mirror_list_path = nil
-cron_package = nil
-httpd_service = nil
+httpd_service = get_httpd_pkg_name
 httpd_conf_path = nil
 
 case node[:platform_family]
 when 'debian'
   mirror_list_path = '/etc/apt/mirror.list'
-  cron_package = 'cron'
-  httpd_service = 'apache2'
   httpd_conf_path = "/etc/#{httpd_service}/conf.d/apt-mirror"
 when 'rhel'
   mirror_list_path = '/etc/apt-mirror.list'
-  cron_package = 'crontabs'
-  httpd_service = 'httpd'
   httpd_conf_path = "/etc/#{httpd_service}/conf.d/apt-mirror.conf"
 end
 
@@ -47,7 +67,7 @@ template mirror_list_path do
   mode '0644'
 end
 
-pkg = cron_package
+pkg = get_cron_pkg_name
 resources(:package => pkg) rescue package pkg do
   action :install
 end
index b1fa6e4..d8d88e6 100644 (file)
 #
 
 <%
-user = nil
 command = nil
 
 case node['platform_family']
 when 'debian'
-  user = 'apt-mirror'
   command = '/usr/bin/apt-mirror'
 when 'rhel'
-  user = 'root'
   command = '/usr/sbin/apt-mirror'
 end
 -%>
-<%= node['apt_utils']['mirror']['cron_period'] %>      <%= user %>     <%= command %> > <%= node['apt_utils']['mirror']['base_path'] %>/var/cron.log
+<%= node['apt_utils']['mirror']['cron_period'] %>      <%= node['apt_utils']['mirror']['user'] %>      <%= command %> > <%= node['apt_utils']['mirror']['base_path'] %>/var/cron.log
index 51e6a84..2b330d8 100644 (file)
@@ -21,5 +21,9 @@ default['cdh']['version'] = '4.3.1'
 default['cdh']['archive_url'] = 'http://archive.cloudera.com'  # or local mirror site.
 default['cdh']['yum_repo']['with_gplextras'] = false  # LZO etc. CDH4 only.
 default['cdh']['yum_repo']['update'] = false
+
+default['cdh']['yum_mirror']['user'] = 'yum-mirror'
+default['cdh']['yum_mirror']['cron_period'] = '#0 4   * * *'  # default: inactive
+default['cdh']['yum_mirror']['base_path'] = '/var/spool/cdh-mirror'
 #default['cdh'][''] = 
 
index 3ce90c1..d360141 100644 (file)
 def get_repo_urls(cdh_version, node_platform, node_platform_version, kernel_machine)
   platform = nil
   case node_platform
-    when 'centos', 'rhel'
-      platform = 'redhat'
+    when 'centos', 'rhel' then platform = 'redhat'
   end
   platform_major_version = node_platform_version.split('.')[0]
   
   platform_ctx = nil
   normalized_kernel_machine = nil
   case cdh_version.split(/[.u]/)[0]
-    when '4'
-      normalized_kernel_machine = (platform_major_version == '5') \
-        ? 'x86_64' \
-        : kernel_machine
-      normalized_kernel_machine = (normalized_kernel_machine == 'i686') \
-        ? 'i386' \
-        : normalized_kernel_machine
-      platform_ctx = "#{platform}/#{platform_major_version}/#{normalized_kernel_machine}"
-    when '3'
-      platform_ctx = (platform_major_version == '5') \
-        ? "#{platform}" \
-        : "#{platform}/#{platform_major_version}/x86_64"
+  when '4'
+    normalized_kernel_machine = (platform_major_version == '5') \
+      ? 'x86_64' \
+      : kernel_machine
+    normalized_kernel_machine = (normalized_kernel_machine == 'i686') \
+      ? 'i386' \
+      : normalized_kernel_machine
+    platform_ctx = "#{platform}/#{platform_major_version}/#{normalized_kernel_machine}"
+  when '3'
+    platform_ctx = (platform_major_version == '5') \
+      ? "#{platform}" \
+      : "#{platform}/#{platform_major_version}/x86_64"
   end
 
   cdh_repo_pkg = nil
@@ -47,21 +46,21 @@ def get_repo_urls(cdh_version, node_platform, node_platform_version, kernel_mach
   cdh_repo_key_ctx = nil
   gplextras_repo_file_ctx = nil
   case cdh_version
-    when '4.4.0', '4.3.1', '4.3.0', '4.2.1', '4.2.0'
-      # YARN: 2.0.0+1475, 2.0.0+1367, 2.0.0+1357, 2.0.0+959, 2.0.0+922
-      # MRv1: 2.0.0+1475, 2.0.0+1367, 2.0.0+1357, 0.20.2+1358, 0.20.2+1341
-      cdh_repo_pkg = "cloudera-cdh"
-      cdh_repo_ctx = "cdh4/one-click-install/#{platform_ctx}/#{cdh_repo_pkg}-4-0.#{normalized_kernel_machine}.rpm"
-      cdh_repo_key_ctx = "cdh4/#{platform}/#{platform_major_version}/x86_64/cdh/RPM-GPG-KEY-cloudera"
-      gplextras_repo_file_ctx = "gplextras/#{platform_ctx}/gplextras/cloudera-gplextras4.repo"
-    when '3u6', '3u5'  # End of Maintenance (EOM): June 20th, 2013.
-      # 0.20.2+923.475, 0.20.2+923.421
-      cdh_repo_pkg = 'cdh3-repository'
-      cdh_repo_ctx = "#{platform_ctx}/cdh/#{cdh_repo_pkg}-1.0-1.noarch.rpm"
-      cdh_repo_key_ctx = "#{platform_ctx}/cdh/RPM-GPG-KEY-cloudera"
-      gplextras_repo_file_ctx = nil
-    else
-      Chef::Application.fatal!("Non supported version: #{cdh_version}")
+  when '4.4.0', '4.3.1', '4.3.0', '4.2.1', '4.2.0'
+    # YARN: 2.0.0+1475, 2.0.0+1367, 2.0.0+1357, 2.0.0+959, 2.0.0+922
+    # MRv1: 2.0.0+1475, 2.0.0+1367, 2.0.0+1357, 0.20.2+1358, 0.20.2+1341
+    cdh_repo_pkg = "cloudera-cdh"
+    cdh_repo_ctx = "cdh4/one-click-install/#{platform_ctx}/#{cdh_repo_pkg}-4-0.#{normalized_kernel_machine}.rpm"
+    cdh_repo_key_ctx = "cdh4/#{platform}/#{platform_major_version}/x86_64/cdh/RPM-GPG-KEY-cloudera"
+    gplextras_repo_file_ctx = "gplextras/#{platform_ctx}/gplextras/cloudera-gplextras4.repo"
+  when '3u6', '3u5'  # End of Maintenance (EOM): June 20th, 2013.
+    # 0.20.2+923.475, 0.20.2+923.421
+    cdh_repo_pkg = 'cdh3-repository'
+    cdh_repo_ctx = "#{platform_ctx}/cdh/#{cdh_repo_pkg}-1.0-1.noarch.rpm"
+    cdh_repo_key_ctx = "#{platform_ctx}/cdh/RPM-GPG-KEY-cloudera"
+    gplextras_repo_file_ctx = nil
+  else
+    Chef::Application.fatal!("Non supported version: #{cdh_version}")
   end
 
   download_site_url = node['cdh']['archive_url']
@@ -108,10 +107,10 @@ if node[:platform_family] == 'rhel' then
   if node['cdh']['yum_repo']['with_gplextras'] && !gplextras_repo_file_url.nil? then
     gplextras_repo_file = nil
     case node[:platform]
-      when 'centos', 'rhel'
-        gplextras_repo_file = '/etc/yum.repos.d/cloudera-gplextras4.repo'
-      when 'suse'
-        gplextras_repo_file = '/etc/zypp/repos.d/cloudera-gplextras4.repo'
+    when 'centos', 'rhel'
+      gplextras_repo_file = '/etc/yum.repos.d/cloudera-gplextras4.repo'
+    when 'suse'
+      gplextras_repo_file = '/etc/zypp/repos.d/cloudera-gplextras4.repo'
     end
   
     gplextras_repo_add_command \
diff --git a/cookbooks/commons/CHANGELOG.md b/cookbooks/commons/CHANGELOG.md
new file mode 100644 (file)
index 0000000..47e9ff3
--- /dev/null
@@ -0,0 +1,13 @@
+commons CHANGELOG
+=================
+
+This file is used to list changes made in each version of the commons cookbook.
+
+0.1.0
+-----
+- [your_name] - Initial release of commons
+
+- - -
+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/commons/README.md b/cookbooks/commons/README.md
new file mode 100644 (file)
index 0000000..a457b14
--- /dev/null
@@ -0,0 +1,68 @@
+commons 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` - commons needs toaster to brown your bagel.
+
+Attributes
+----------
+TODO: List you cookbook attributes here.
+
+e.g.
+#### commons::default
+<table>
+  <tr>
+    <th>Key</th>
+    <th>Type</th>
+    <th>Description</th>
+    <th>Default</th>
+  </tr>
+  <tr>
+    <td><tt>['commons']['bacon']</tt></td>
+    <td>Boolean</td>
+    <td>whether to include bacon</td>
+    <td><tt>true</tt></td>
+  </tr>
+</table>
+
+Usage
+-----
+#### commons::default
+TODO: Write usage instructions for each cookbook.
+
+e.g.
+Just include `commons` in your node's `run_list`:
+
+```json
+{
+  "name":"my_node",
+  "run_list": [
+    "recipe[commons]"
+  ]
+}
+```
+
+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/commons/libraries/package_utils.rb b/cookbooks/commons/libraries/package_utils.rb
new file mode 100644 (file)
index 0000000..9638698
--- /dev/null
@@ -0,0 +1,54 @@
+#
+# Cookbook Name:: PackageUtils
+# Library:: Helper
+#
+# 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.
+#
+
+module Commons
+  module PackageUtils
+    def get_cron_pkg_name
+      case node[:platform_family]
+      when 'debian'then return 'cron'
+      when 'rhel'  then return 'crontabs'
+      end
+    end
+
+
+    def get_httpd_pkg_name
+      case node[:platform_family]
+      when 'debian'then return 'apache2'
+      when 'rhel'  then return 'httpd'
+      end
+    end
+
+
+    def get_jsvc_pkg_name
+      case node[:platform_family]
+      when 'debian' then return 'jsvc'
+      when 'rhel'   then return 'jakarta-commons-daemon-jsvc'
+      end
+    end
+
+
+    def get_libbz2_pkg_name
+      case node[:platform_family]
+      when 'debian' then return 'libbz2-1.0'
+      when 'rhel'   then return 'bzip2-libs'
+      end
+    end
+  end
+end
+
diff --git a/cookbooks/commons/metadata.rb b/cookbooks/commons/metadata.rb
new file mode 100644 (file)
index 0000000..ef28cd9
--- /dev/null
@@ -0,0 +1,7 @@
+name             'commons'
+maintainer       'whitestar'
+maintainer_email ''
+license          'Apache 2.0'
+description      'Installs/Configures commons'
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
+version          '0.1.0'
diff --git a/cookbooks/commons/recipes/default.rb b/cookbooks/commons/recipes/default.rb
new file mode 100644 (file)
index 0000000..bcadb32
--- /dev/null
@@ -0,0 +1,18 @@
+#
+# Cookbook Name:: commons
+# 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.
+#
index 5815d01..2249f31 100644 (file)
@@ -17,6 +17,8 @@
 # limitations under the License.
 #
 
+module Hadoop
+
 module Helper
   USERS_V1 = {
     :hadoop => {:name => 'hadoop', :uid => 10001},
@@ -114,20 +116,16 @@ module Helper
 
   def get_users(major_version)
     case major_version
-      when '1'
-        return USERS_V1
-      when '2'
-        return USERS_V2
+    when '1' then return USERS_V1
+    when '2' then return USERS_V2
     end
   end
 
 
   def get_limits_files(major_version)
     case major_version
-      when '1'
-        return LIMITS_FILES_V1
-      when '2'
-        return LIMITS_FILES_V2
+    when '1' then return LIMITS_FILES_V1
+    when '2' then return LIMITS_FILES_V2
     end
   end
 
@@ -248,26 +246,6 @@ module Helper
   end
 
 
-  def get_jsvc_pkg_name
-    case node[:platform_family]
-    when 'debian'
-      return 'jsvc'
-    when 'rhel'
-      return 'jakarta-commons-daemon-jsvc'
-    end
-  end
-
-
-  def get_libbz2_pkg_name
-    case node[:platform_family]
-    when 'debian'
-      return 'libbz2-1.0'
-    when 'rhel'
-      return 'bzip2-libs'
-    end
-  end
-
-
   def get_cgroup_pkg_name
     case node[:platform_family]
     when 'debian'
@@ -331,3 +309,6 @@ module Helper
     end
   end
 end
+
+end
+
index 8ca1a24..f9e094b 100644 (file)
@@ -10,5 +10,6 @@ version          '0.1.0'
   supports os
 end
 
-depends          'java'
 depends          'grid'
+depends          'java'
+depends          'commons'
index 6f97d64..4883dea 100644 (file)
@@ -19,7 +19,9 @@
 
 require 'digest/sha2'
 
-::Chef::Recipe.send(:include, Helper)
+::Chef::Recipe.send(:include, Commons::PackageUtils)
+
+::Chef::Recipe.send(:include, Hadoop::Helper)
 
 conf_files = nil
 
index 4b13b0d..05f312f 100644 (file)
@@ -17,7 +17,7 @@
 # limitations under the License.
 #
 
-::Chef::Recipe.send(:include, Helper)
+::Chef::Recipe.send(:include, Hadoop::Helper)
 
 packages = nil
 
index 1856c5a..b34f71c 100644 (file)
@@ -17,7 +17,7 @@
 # limitations under the License.
 #
 
-::Chef::Recipe.send(:include, Helper)
+::Chef::Recipe.send(:include, Hadoop::Helper)
 
 install_root = '/usr/lib/hadoop'
 conf_dir = '/etc/hadoop/conf'
index cac3bdd..60b45b1 100644 (file)
@@ -17,7 +17,9 @@
 # limitations under the License.
 #
 
-::Chef::Recipe.send(:include, Helper)
+::Chef::Recipe.send(:include, Commons::PackageUtils)
+
+::Chef::Recipe.send(:include, Hadoop::Helper)
 
 install_root = '/usr/lib/hadoop'
 conf_dir = '/etc/hadoop/conf'
index 782b66f..f961735 100644 (file)
@@ -30,7 +30,7 @@
 #   https://github.com/hortonworks/hadoop-lzo/tree/master
 #
 
-::Chef::Recipe.send(:include, Helper)
+::Chef::Recipe.send(:include, Hadoop::Helper)
 
 packages = nil
 
index 0532f4a..1d20c97 100644 (file)
 # limitations under the License.
 #
 
+default['yum_utils']['repos']['CentOS-Base'] = {
+  'mirrorlist_ctx' => '', # default: inactive
+  #'mirrorlist_ctx' => 'http://mirrorlist.centos.org',
+  'baseurl_ctx' => '',  # default: inactive
+  #'baseurl_ctx' => 'http://mirror.centos.org/centos',
+  #'baseurl_ctx' => 'http://ftp.grid.example.com/centos',
+  #'baseurl_ctx' => 'http://localhost/centos',
+  'gpgkey' => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6'
+}
+default['yum_utils']['repos']['epel'] = {
+  'mirrorlist_ctx' => '', # default: inactive
+  #'mirrorlist_ctx' => 'http://mirrors.fedoraproject.org',
+  'baseurl_ctx' => '',  # default: inactive
+  #'baseurl_ctx' => 'http://ftp.grid.example.com/fedora/epel',
+  #'baseurl_ctx' => 'http://localhost/fedora/epel',
+  'gpgkey' => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6'
+}
+
+default['yum_utils']['mirror']['user'] = 'yum-mirror'
 default['yum_utils']['mirror']['cron_period'] = '#0 2  * * *'  # default: inactive
 default['yum_utils']['mirror']['base_path'] = '/var/spool/yum-mirror'
 default['yum_utils']['mirror']['rsync_sources'] = [
 =begin
-# examples
+  # default: inactive
+  # examples
   # CentOS
   # http://www.centos.org/modules/tinycontent/index.php?id=30
   {
     'url' => 'rsync://ftp.riken.jp/centos/',
-    'rsync_opts' => '-avSH --stats --partial --delete --exclude /[1-5]*/ --exclude /6.[0-3]/ --exclude local* --exclude isos --exclude ppc*',
+    'rsync_opts' => '-avSH --stats --partial --delete --safe-links --exclude /[1-5]*/ --exclude /6.[0-3]/ --exclude local* --exclude isos --exclude ppc*',
     'http_alias' => '/centos'
   },
   # EPEL
   # http://mirrors.fedoraproject.org/publiclist/EPEL/
   {
     'url' => 'rsync://ftp.riken.jp/fedora/epel/',
-    'rsync_opts' => '-avSH --stats --partial --delete --exclude /[1-5]*/ --exclude local* --exclude isos --exclude ppc*',
+    'rsync_opts' => '-avSH --stats --partial --delete --safe-links --exclude /[1-5]*/ --exclude local* --exclude isos --exclude ppc*',
     'http_alias' => '/fedora/epel'
   },
 =end
index 68d708b..b947284 100644 (file)
@@ -5,3 +5,5 @@ license          'Apache 2.0'
 description      'Installs/Configures yum_utils'
 long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
 version          '0.1.0'
+
+depends  'commons'
index 888761f..1509150 100644 (file)
 # limitations under the License.
 #
 
+::Chef::Recipe.send(:include, Commons::PackageUtils)
+
+mirror_user = node['yum_utils']['mirror']['user']
+base_path = node['yum_utils']['mirror']['base_path']
+
+resources(:group => mirror_user) rescue group mirror_user do
+  system true
+  action :create
+end
+
+resources(:user => mirror_user) rescue user mirror_user do
+  gid mirror_user
+  system true
+  home base_path
+  shell '/bin/sh'
+  password nil
+  action :create
+end
+
+httpd_service = get_httpd_pkg_name
+httpd_conf_path = nil
+
 case node[:platform_family]
 when 'debian'
-  cron_package = 'cron'
-  httpd_service = 'apache2'
   httpd_conf_path = "/etc/#{httpd_service}/conf.d/yum-mirror"
 when 'rhel'
-  cron_package = 'crontabs'
-  httpd_service = 'httpd'
   httpd_conf_path = "/etc/#{httpd_service}/conf.d/yum-mirror.conf"
 end
 
@@ -33,19 +51,19 @@ resources(:package => pkg) rescue package pkg do
   action :install
 end
 
-pkg = cron_package
+pkg = get_cron_pkg_name
 resources(:package => pkg) rescue package pkg do
   action :install
 end
 
-base_path = node['yum_utils']['mirror']['base_path']
-%w{
-  mirror
-  var
-}.each {|subdir|
+[
+  '',
+  'mirror',
+  'var',
+].each {|subdir|
   directory "#{base_path}/#{subdir}" do
-    owner 'root'
-    group 'root'
+    owner mirror_user
+    group mirror_user
     mode '0755'
     recursive true
   end
@@ -58,8 +76,8 @@ node['yum_utils']['mirror']['rsync_sources'].each {|source|
     local_path.chop!
   end
   directory local_path do
-    owner 'root'
-    group 'root'
+    owner mirror_user
+    group mirror_user
     mode '0755'
     recursive true
   end
diff --git a/cookbooks/yum_utils/recipes/repos.rb b/cookbooks/yum_utils/recipes/repos.rb
new file mode 100644 (file)
index 0000000..8558f9e
--- /dev/null
@@ -0,0 +1,34 @@
+#
+# Cookbook Name:: yum_utils
+# Recipe:: repos
+#
+# 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.
+#
+
+if node[:platform_family] == 'rhel' then
+  node['yum_utils']['repos'].each {|name, repo|
+    if !repo['mirrorlist_ctx'].empty? || !repo['baseurl_ctx'].empty? then
+      template "/etc/yum.repos.d/#{name}.repo" do
+        source "etc/yum.repos.d/#{name}.repo"
+        owner 'root'
+        group 'root'
+        mode '0644'
+      end
+    end
+  }
+else
+  # do nothig.
+end
+
index bb35ec9..5a9c2af 100644 (file)
@@ -16,4 +16,4 @@
 # limitations under the License.
 #
 
-<%= node['yum_utils']['mirror']['cron_period'] %>      root    /usr/local/bin/yum-mirror > <%= node['yum_utils']['mirror']['base_path'] %>/var/cron.log
+<%= node['yum_utils']['mirror']['cron_period'] %>      <%= node['yum_utils']['mirror']['user'] %>      /usr/local/bin/yum-mirror > <%= node['yum_utils']['mirror']['base_path'] %>/var/cron.log
diff --git a/cookbooks/yum_utils/templates/default/etc/yum.repos.d/CentOS-Base.repo b/cookbooks/yum_utils/templates/default/etc/yum.repos.d/CentOS-Base.repo
new file mode 100644 (file)
index 0000000..85fc828
--- /dev/null
@@ -0,0 +1,77 @@
+# CentOS-Base.repo
+#
+# The mirror system uses the connecting IP address of the client and the
+# update status of each mirror to pick mirrors that are updated to and
+# geographically close to the client.  You should use this for CentOS updates
+# unless you are manually picking other mirrors.
+#
+# If the mirrorlist= does not work for you, as a fall back you can try the 
+# remarked out baseurl= line instead.
+#
+#
+
+<%
+mirrorlist_ctx = node['yum_utils']['repos']['CentOS-Base']['mirrorlist_ctx']
+baseurl_ctx = node['yum_utils']['repos']['CentOS-Base']['baseurl_ctx']
+gpgkey = node['yum_utils']['repos']['CentOS-Base']['gpgkey']
+-%>
+[base]
+name=CentOS-$releasever - Base
+<% if !mirrorlist_ctx.empty? then -%>
+mirrorlist=<%= mirrorlist_ctx %>/?release=$releasever&arch=$basearch&repo=os
+<% end -%>
+<% if !baseurl_ctx.empty? then -%>
+baseurl=<%= baseurl_ctx %>/$releasever/os/$basearch/
+<% end -%>
+gpgcheck=1
+gpgkey=<%= gpgkey %>
+
+#released updates 
+[updates]
+name=CentOS-$releasever - Updates
+<% if !mirrorlist_ctx.empty? then -%>
+mirrorlist=<%= mirrorlist_ctx %>/?release=$releasever&arch=$basearch&repo=updates
+<% end -%>
+<% if !baseurl_ctx.empty? then -%>
+baseurl=<%= baseurl_ctx %>/$releasever/updates/$basearch/
+<% end -%>
+gpgcheck=1
+gpgkey=<%= gpgkey %>
+
+#additional packages that may be useful
+[extras]
+name=CentOS-$releasever - Extras
+<% if !mirrorlist_ctx.empty? then -%>
+mirrorlist=<%= mirrorlist_ctx %>/?release=$releasever&arch=$basearch&repo=extras
+<% end -%>
+<% if !baseurl_ctx.empty? then -%>
+baseurl=<%= baseurl_ctx %>/$releasever/extras/$basearch/
+<% end -%>
+gpgcheck=1
+gpgkey=<%= gpgkey %>
+
+#additional packages that extend functionality of existing packages
+[centosplus]
+name=CentOS-$releasever - Plus
+<% if !mirrorlist_ctx.empty? then -%>
+mirrorlist=<%= mirrorlist_ctx %>/?release=$releasever&arch=$basearch&repo=centosplus
+<% end -%>
+<% if !baseurl_ctx.empty? then -%>
+baseurl=<%= baseurl_ctx %>/$releasever/centosplus/$basearch/
+<% end -%>
+gpgcheck=1
+enabled=0
+gpgkey=<%= gpgkey %>
+
+#contrib - packages by Centos Users
+[contrib]
+name=CentOS-$releasever - Contrib
+<% if !mirrorlist_ctx.empty? then -%>
+mirrorlist=<%= mirrorlist_ctx %>/?release=$releasever&arch=$basearch&repo=contrib
+<% end -%>
+<% if !baseurl_ctx.empty? then -%>
+baseurl=<%= baseurl_ctx %>/$releasever/contrib/$basearch/
+<% end -%>
+gpgcheck=1
+enabled=0
+gpgkey=<%= gpgkey %>
diff --git a/cookbooks/yum_utils/templates/default/etc/yum.repos.d/epel.repo b/cookbooks/yum_utils/templates/default/etc/yum.repos.d/epel.repo
new file mode 100644 (file)
index 0000000..951ef61
--- /dev/null
@@ -0,0 +1,16 @@
+<%
+mirrorlist_ctx = node['yum_utils']['repos']['epel']['mirrorlist_ctx']
+baseurl_ctx = node['yum_utils']['repos']['epel']['baseurl_ctx']
+gpgkey = node['yum_utils']['repos']['epel']['gpgkey']
+-%>
+[epel]
+name=Extra Packages for Enterprise Linux
+<% if !mirrorlist_ctx.empty? then -%>
+mirrorlist=<%= mirrorlist_ctx %>/mirrorlist?repo=epel-$releasever&arch=$basearch
+<% end -%>
+<% if !baseurl_ctx.empty? then -%>
+baseurl=<%= baseurl_ctx %>/$releasever/$basearch
+<% end -%>
+gpgcheck=1
+gpgkey=<%= gpgkey %>
+enabled=1
index ef31fe4..62e1e92 100644 (file)
@@ -18,8 +18,9 @@
 <%
 @rsync_sources.each do |source|
 -%>
-date
+echo -n 'Begin time: '; date
 <%= source['rsync_command'] %>
+echo -n 'End time: '; date
 
 <%
 end
diff --git a/nodes/localhost-apache-mirror.json b/nodes/localhost-apache-mirror.json
new file mode 100644 (file)
index 0000000..f1138c0
--- /dev/null
@@ -0,0 +1,5 @@
+{
+  "run_list": [
+    "role[apache-mirror]"
+  ]
+}
diff --git a/roles/apache-mirror.rb b/roles/apache-mirror.rb
new file mode 100644 (file)
index 0000000..3b2e1d0
--- /dev/null
@@ -0,0 +1,29 @@
+#
+# 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.
+#
+
+name 'apache-mirror'
+description 'Apache mirror server.'
+
+run_list(
+  'recipe[apache_utils::mirror]',
+)
+
+#env_run_lists()
+
+default_attributes(
+)
+
+#override_attributes()
index 8d8e874..fffa715 100644 (file)
@@ -24,8 +24,10 @@ description 'Grid distribution node'
 run_list(
   'role[node_commons]',
   'role[apt-mirror]',
-  'role[apt-source]',
+  #'role[apt-source]',
   'role[yum-mirror]',
+  #'role[yum-repos]',
+  'role[apache-mirror]',
   #'role[ganglia-gmond]',
 )
 
@@ -53,19 +55,25 @@ default_attributes(
 )
 
 override_attributes(
+  'apache_utils' => {
+    'mirror' => {
+      'cron_period' => '#15 23   * * *'
+    }
+  },
   'apt_utils' => {
     'source' => {
       'apt_lines' => [
         'deb http://cdn.debian.net/debian wheezy main contrib non-free',
         'deb http://cdn.debian.net/debian wheezy-updates main contrib',
         'deb http://cdn.debian.net/debian wheezy-backports main contrib non-free',
-        'deb http://localhost/debian wheezy main contrib non-free',
-        'deb http://localhost/debian wheezy-updates main contrib',
-        'deb http://localhost/debian wheezy-backports main contrib non-free',
+        # self test
+        #'deb http://localhost/debian wheezy main contrib non-free',
+        #'deb http://localhost/debian wheezy-updates main contrib',
+        #'deb http://localhost/debian wheezy-backports main contrib non-free',
       ]
     },
     'mirror' => {
-      'cron_period' => '0 22   * * *',
+      'cron_period' => '#0 22   * * *',
       #'cron_period' => '0 4   * * *',
       'country' => 'jp',
       'distributions' => {
@@ -74,6 +82,9 @@ override_attributes(
             'wheezy',
             'wheezy-updates',
             'wheezy-backports',
+            'squeeze',
+            'squeeze-updates',
+            'squeeze-backports',
           ],
           'architectures' => [
             'amd64',
@@ -90,18 +101,37 @@ override_attributes(
     }
   },
   'yum_utils' => {
+    'repos' => {
+      'CentOS-Base' => {
+        'mirrorlist_ctx' => '', # default: inactive
+        #'mirrorlist_ctx' => 'http://mirrorlist.centos.org',
+        'baseurl_ctx' => '',  # default: inactive
+        #'baseurl_ctx' => 'http://mirror.centos.org/centos',
+        #'baseurl_ctx' => 'http://ftp.grid.example.com/centos',
+        #'baseurl_ctx' => 'http://localhost/centos',
+        'gpgkey' => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6'
+      },   
+      'epel' => {
+        'mirrorlist_ctx' => '', # default: inactive
+        #'mirrorlist_ctx' => 'http://mirrors.fedoraproject.org',
+        'baseurl_ctx' => '',  # default: inactive
+        #'baseurl_ctx' => 'http://ftp.grid.example.com/fedora/epel',
+        #'baseurl_ctx' => 'http://localhost/fedora/epel',
+        'gpgkey' => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6'
+      }
+    },
     'mirror' => {
-      'cron_period' => '0 21   * * *',
+      'cron_period' => '#0 21   * * *',
       #'cron_period' => '0 4   * * *',
       'rsync_sources' => [
         {
           'url' => 'rsync://ftp.riken.jp/centos/',
-          'rsync_opts' => '-avSH --stats --partial --delete --exclude /[1-5]*/ --exclude /6.[0-3]/ --exclude local* --exclude isos --exclude ppc*',
+          'rsync_opts' => '-avSH --stats --partial --delete --safe-links --exclude /[1-5]*/ --exclude /6.[0-3]/ --exclude local* --exclude isos --exclude ppc*',
           'http_alias' => '/centos'
         },
         {
           'url' => 'rsync://ftp.riken.jp/fedora/epel/',
-          'rsync_opts' => '-avSH --stats --partial --delete --exclude /[1-5]*/ --exclude local* --exclude isos --exclude ppc*',
+          'rsync_opts' => '-avSH --stats --partial --delete --safe-links --exclude /[1-5]*/ --exclude local* --exclude isos --exclude ppc*',
           'http_alias' => '/fedora/epel'
         }
       ]
diff --git a/roles/yum-repos.rb b/roles/yum-repos.rb
new file mode 100644 (file)
index 0000000..424045a
--- /dev/null
@@ -0,0 +1,13 @@
+name 'yum-repos'
+description 'YUM repositories configuration.'
+
+run_list(
+  'recipe[yum_utils::repos]',
+)
+
+#env_run_lists()
+
+default_attributes(
+)
+
+#override_attributes()