default['apt_utils']['mirror']['nthreads'] = '20'
default['apt_utils']['mirror']['_tilde'] = '0'
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'] = {
'code_names' => [
'wheezy',
+#
+# 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.
+#
+
<%
country = node['apt_utils']['mirror']['country']
+#
+# 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.
+#
+
############# config ##################
#
set base_path <%= node['apt_utils']['mirror']['base_path'] %>
+#
+# 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['apt_utils']['source']['apt_lines'].each do |apt_line| -%>
<%= apt_line %>
<% end -%>
#
# Regular cron jobs for the apt-mirror package
#
+# 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.
+#
+
<%
user = nil
command = nil
# limitations under the License.
#
-default['yum_utils']['mirror']['cron_period'] = '#0 4 * * *' # default: negative
+default['yum_utils']['mirror']['cron_period'] = '#0 2 * * *' # default: inactive
default['yum_utils']['mirror']['base_path'] = '/var/spool/yum-mirror'
-default['yum_utils']['mirror']['country'] = 'us' # or jp,...
+default['yum_utils']['mirror']['rsync_sources'] = [
+=begin
+# 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*',
+ '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*',
+ 'http_alias' => '/fedora/epel'
+ },
+=end
+]
# limitations under the License.
#
+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
+
pkg = 'rsync'
resources(:package => pkg) rescue package pkg do
action :install
end
+pkg = cron_package
+resources(:package => pkg) rescue package pkg do
+ action :install
+end
+
+base_path = node['yum_utils']['mirror']['base_path']
+%w{
+ mirror
+ var
+}.each {|subdir|
+ directory "#{base_path}/#{subdir}" do
+ owner 'root'
+ group 'root'
+ mode '0755'
+ recursive true
+ end
+}
+
+rsync_sources = []
+node['yum_utils']['mirror']['rsync_sources'].each {|source|
+ local_path = "#{base_path}/mirror/#{source['url'].gsub(/^rsync:\/\//, '')}"
+ if local_path.end_with?('/') then
+ local_path.chop!
+ end
+ directory local_path do
+ owner 'root'
+ group 'root'
+ 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/yum-mirror' do
source 'usr/local/bin/yum-mirror'
owner 'root'
group 'root'
mode '0755'
+ variables({
+ :rsync_sources => rsync_sources
+ })
end
template '/etc/cron.d/yum-mirror' do
mode '0644'
end
-apache_pkg = nil
-apache_service = nil
-case node[:platform_family]
-when 'debian'
- apache_pkg = 'apache2'
- apache_service = 'apache2'
-when 'rhel'
- apache_pkg = 'httpd'
- apache_service = 'httpd'
-end
-
-resources(:package => apache_pkg) rescue package apache_pkg do
+pkg = httpd_service
+resources(:package => pkg) rescue package pkg do
action :install
end
-resources(:service => apache_service) rescue service apache_service do
+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/yum-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 NameWidth=* +SuppressDescription
+ AllowOverride FileInfo Indexes
+ Order Deny,Allow
+ Allow from all
+ ErrorDocument 404 default
+</Directory>
+
+<%
+end
+-%>
+
#
# Regular cron jobs for the yum-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['yum_utils']['mirror']['cron_period'] %> root /usr/local/bin/yum-mirror > <%= node['yum_utils']['mirror']['base_path'] %>/var/cron.log
+#!/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|
+-%>
+date
+<%= source['rsync_command'] %>
+
+<%
+end
+-%>
+
+#
+# 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 'apt-mirror'
description 'APT mirror server.'
+#
+# 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.
+#
+
$LOAD_PATH.push("#{File.dirname(__FILE__)}/../_lib")
#${chef-repo}/_lib/grid.rb
require 'grid'
'role[node_commons]',
'role[apt-mirror]',
'role[apt-source]',
+ 'role[yum-mirror]',
#'role[ganglia-gmond]',
)
'non-free'
]
}
- },
- },
+ }
+ }
+ },
+ 'yum_utils' => {
+ 'mirror' => {
+ '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*',
+ '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*',
+ 'http_alias' => '/fedora/epel'
+ }
+ ]
+ }
},
'ganglia' => {
# gmond
+#
+# 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 'yum-mirror'
description 'YUM mirror server.'