--- /dev/null
+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.
--- /dev/null
+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
--- /dev/null
+#
+# 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'
+ }
+]
+
--- /dev/null
+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'
--- /dev/null
+#
+# 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.
+#
--- /dev/null
+#
+# 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
+
--- /dev/null
+#
+# 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
+-%>
+
--- /dev/null
+#
+# 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
--- /dev/null
+#!/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
+-%>
+
--- /dev/null
+#!/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
+-%>
+
'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'
# 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' => [
]
}
default['apt_utils']['mirror']['distribution']['ubuntu'] = {
- # default: empty
+ # default: empty (inactive)
'code_names' => [
#'raring',
#'raring-updates',
description 'Installs/Configures apt_utils'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
+
+depends 'commons'
# 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
mode '0644'
end
-pkg = cron_package
+pkg = get_cron_pkg_name
resources(:package => pkg) rescue package pkg do
action :install
end
#
<%
-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
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'][''] =
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
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']
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 \
--- /dev/null
+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.
--- /dev/null
+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
--- /dev/null
+#
+# 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
+
--- /dev/null
+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'
--- /dev/null
+#
+# 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.
+#
# limitations under the License.
#
+module Hadoop
+
module Helper
USERS_V1 = {
:hadoop => {:name => 'hadoop', :uid => 10001},
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
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'
end
end
end
+
+end
+
supports os
end
-depends 'java'
depends 'grid'
+depends 'java'
+depends 'commons'
require 'digest/sha2'
-::Chef::Recipe.send(:include, Helper)
+::Chef::Recipe.send(:include, Commons::PackageUtils)
+
+::Chef::Recipe.send(:include, Hadoop::Helper)
conf_files = nil
# limitations under the License.
#
-::Chef::Recipe.send(:include, Helper)
+::Chef::Recipe.send(:include, Hadoop::Helper)
packages = nil
# 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'
# 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'
# https://github.com/hortonworks/hadoop-lzo/tree/master
#
-::Chef::Recipe.send(:include, Helper)
+::Chef::Recipe.send(:include, Hadoop::Helper)
packages = nil
# 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
description 'Installs/Configures yum_utils'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
+
+depends 'commons'
# 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
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
local_path.chop!
end
directory local_path do
- owner 'root'
- group 'root'
+ owner mirror_user
+ group mirror_user
mode '0755'
recursive true
end
--- /dev/null
+#
+# 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
+
# 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
--- /dev/null
+# 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 %>
--- /dev/null
+<%
+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
<%
@rsync_sources.each do |source|
-%>
-date
+echo -n 'Begin time: '; date
<%= source['rsync_command'] %>
+echo -n 'End time: '; date
<%
end
--- /dev/null
+{
+ "run_list": [
+ "role[apache-mirror]"
+ ]
+}
--- /dev/null
+#
+# 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()
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]',
)
)
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' => {
'wheezy',
'wheezy-updates',
'wheezy-backports',
+ 'squeeze',
+ 'squeeze-updates',
+ 'squeeze-backports',
],
'architectures' => [
'amd64',
}
},
'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'
}
]
--- /dev/null
+name 'yum-repos'
+description 'YUM repositories configuration.'
+
+run_list(
+ 'recipe[yum_utils::repos]',
+)
+
+#env_run_lists()
+
+default_attributes(
+)
+
+#override_attributes()