Add local repo

Change-Id: I70b2bcbdf3d068aef48fa0162a192d19416eaa83
This commit is contained in:
Xicheng Chang 2014-09-26 11:53:22 -07:00
parent 0570b42764
commit 67d35b643a
7 changed files with 71 additions and 28 deletions

View File

@ -27,7 +27,7 @@ if platform_family?("rhel")
"collectd-java",
"collectd-libnotify",
"collectd-liboping",
"collectd-libvirt",
# "collectd-libvirt",
"collectd-memcache",
"collectd-mysql",
"collectd-nginx",

View File

@ -44,4 +44,12 @@ node['mysql']['client']['packages'].each do |name|
resources("package[#{name}]").run_action(:install)
end
chef_gem 'mysql'
if node['local_repo'] == ""
chef_gem 'mysql'
else
gem_package 'mysql' do
options("--clear-sources --source #{node['local_repo']}/gem_repo/")
action :install
version '2.9.1'
end
end

View File

@ -26,6 +26,10 @@ if node['openstack']['image']['syslog']['use']
include_recipe 'openstack-common::logging'
end
if node['local_repo'] != ""
node.override['openstack']['image']['upload_image']['cirros'] = "#{node['local_repo']}/cirros-0.3.2-x86_64-disk.img"
end
platform_options = node['openstack']['image']['platform']
platform_options['image_client_packages'].each do |pkg|
package pkg do

View File

@ -31,34 +31,36 @@ def whyrun_supported?
end
action :create do
# Hack around the lack of "use_inline_resources" before Chef 11 by
# uniquely naming the execute[yum-makecache] resources. Set the
# notifies timing to :immediately for the same reasons. Remove both
# of these when dropping Chef 10 support.
if node['local_repo'] == ""
# Hack around the lack of "use_inline_resources" before Chef 11 by
# uniquely naming the execute[yum-makecache] resources. Set the
# notifies timing to :immediately for the same reasons. Remove both
# of these when dropping Chef 10 support.
template "/etc/yum.repos.d/#{new_resource.repositoryid}.repo" do
if new_resource.source.nil?
source 'repo.erb'
cookbook 'yum'
else
source new_resource.source
template "/etc/yum.repos.d/#{new_resource.repositoryid}.repo" do
if new_resource.source.nil?
source 'repo.erb'
cookbook 'yum'
else
source new_resource.source
end
mode '0644'
variables(:config => new_resource)
notifies :run, "execute[yum-makecache-#{new_resource.repositoryid}]", :immediately
notifies :create, "ruby_block[yum-cache-reload-#{new_resource.repositoryid}]", :immediately
end
mode '0644'
variables(:config => new_resource)
notifies :run, "execute[yum-makecache-#{new_resource.repositoryid}]", :immediately
notifies :create, "ruby_block[yum-cache-reload-#{new_resource.repositoryid}]", :immediately
end
# get the metadata for this repo only
execute "yum-makecache-#{new_resource.repositoryid}" do
command "yum -q makecache --disablerepo=* --enablerepo=#{new_resource.repositoryid}"
action :nothing
end
# get the metadata for this repo only
execute "yum-makecache-#{new_resource.repositoryid}" do
command "yum -q makecache --disablerepo=* --enablerepo=#{new_resource.repositoryid}"
action :nothing
end
# reload internal Chef yum cache
ruby_block "yum-cache-reload-#{new_resource.repositoryid}" do
block { Chef::Provider::Package::Yum::YumCache.instance.reload }
action :nothing
# reload internal Chef yum cache
ruby_block "yum-cache-reload-#{new_resource.repositoryid}" do
block { Chef::Provider::Package::Yum::YumCache.instance.reload }
action :nothing
end
end
end

View File

@ -94,6 +94,9 @@ chkconfig iptables off
chkconfig ip6tables off
$SNIPPET('kickstart_yum.conf')
#if $getVar('local_repo', '') != ''
$SNIPPET('local_repo')
#end if
$SNIPPET('kickstart_ssh')
$SNIPPET('kickstart_ntp')
$SNIPPET('kickstart_limits.conf')

View File

@ -15,6 +15,11 @@ while true; do
let all_nodes_success=1
for node in \\$nodes; do
mkdir -p /var/log/chef/\\$node
#if $getVar("local_repo","") != ""
cat << EOL > /etc/chef/\\$node.json
{"local_repo": "$local_repo"}
EOL
#end if
if [ ! -f "/etc/chef/\\$node.pem" ]; then
cat << EOL > /etc/rsyslog.d/\\$node.conf
\\\\$ModLoad imfile
@ -32,9 +37,9 @@ EOL
service rsyslog restart
fi
if [ -f "/etc/chef/\\$node.done" ]; then
chef-client --node-name \\$node --client_key /etc/chef/\\$node.pem &>> /tmp/chef.log
chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem &>> /tmp/chef.log
else
chef-client --node-name \\$node --client_key /etc/chef/\\$node.pem -L /var/log/chef/\\$node/chef-client.log &>> /tmp/chef.log
chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem -L /var/log/chef/\\$node/chef-client.log &>> /tmp/chef.log
fi
if [ "\\$?" != "0" ]; then
echo "chef-client --node-name \\$node run failed" &>> /tmp/chef.log

View File

@ -0,0 +1,21 @@
mkdir /tmp/backup
mv /etc/yum.repos.d/* /tmp/backup
cat << EOF > /etc/yum.repos.d/Compass.repo
[compass_repo]
name=Compass yum repo
baseurl=$local_repo/compass_repo/
enabled=1
gpgcheck=0
EOF
cat << EOF > /root/.gemrc
---
:backtrace: false
:benchmark: false
:bulk_threshold: 1000
:sources:
- $local_repo/gem_repo/
:update_sources: true
:verbose: true
EOF