make openstack installation support proxy mode

Change-Id: I3d6ce9418aa4763020cc38699dbcc784b4b7c013
This commit is contained in:
xiaodongwang
2015-01-30 14:53:28 -08:00
parent 7cf80ebf74
commit a8bfd97de2
12 changed files with 91 additions and 185 deletions

View File

@@ -46,69 +46,10 @@ end
case node['platform_family'] case node['platform_family']
when 'rhel', 'fedora' when 'rhel', 'fedora'
remote_file "#{Chef::Config['file_cache_path']}/libopkele-2.0.4.tar.gz" do package 'libopkele'
source 'http://kin.klever.net/dist/libopkele-2.0.4.tar.gz' package 'mod_auth_openid'
mode '0644' when 'debian'
checksum '57a5bc753b7e80c5ece1e5968b2051b0ce7ed9ce4329d17122c61575a9ea7648' package 'libapache2-mod-auth-openid'
end
bash 'install libopkele' do
cwd Chef::Config['file_cache_path']
# Ruby 1.8.6 does not have rpartition, unfortunately
syslibdir = node['apache']['lib_dir'][0..node['apache']['lib_dir'].rindex('/')]
code <<-EOH
tar zxvf libopkele-2.0.4.tar.gz
cd libopkele-2.0.4 && ./configure --prefix=/usr --libdir=#{syslibdir}
#{make_cmd} && #{make_cmd} install
EOH
creates "#{syslibdir}/libopkele.a"
end
end
version = node['apache']['mod_auth_openid']['ref']
configure_flags = node['apache']['mod_auth_openid']['configure_flags']
remote_file "#{Chef::Config['file_cache_path']}/mod_auth_openid-#{version}.tar.gz" do
source node['apache']['mod_auth_openid']['source_url']
mode '0644'
action :create_if_missing
end
directory node['apache']['mod_auth_openid']['cache_dir'] do
owner node['apache']['user']
group node['apache']['group']
mode '0700'
end
bash 'untar mod_auth_openid' do
cwd Chef::Config['file_cache_path']
code <<-EOH
tar zxvf mod_auth_openid-#{version}.tar.gz
EOH
creates "#{Chef::Config['file_cache_path']}/mod_auth_openid-#{version}/src/types.h"
end
bash 'compile mod_auth_openid' do
cwd "#{Chef::Config['file_cache_path']}/mod_auth_openid-#{version}"
code <<-EOH
./autogen.sh
./configure #{configure_flags.join(' ')}
perl -pi -e "s/-i -a -n 'authopenid'/-i -n 'authopenid'/g" Makefile
#{make_cmd}
EOH
creates "#{Chef::Config['file_cache_path']}/mod_auth_openid-#{version}/src/.libs/mod_auth_openid.so"
notifies :run, 'bash[install-mod_auth_openid]', :immediately
not_if "test -f #{Chef::Config['file_cache_path']}/mod_auth_openid-#{version}/src/.libs/mod_auth_openid.so"
end
bash 'install-mod_auth_openid' do
cwd "#{Chef::Config['file_cache_path']}/mod_auth_openid-#{version}"
code <<-EOH
#{make_cmd} install
EOH
creates "#{node['apache']['libexecdir']}/mod_auth_openid.so"
notifies :restart, 'service[apache2]'
not_if "test -f #{node['apache']['libexecdir']}/mod_auth_openid.so"
end end
template "#{node['apache']['dir']}/mods-available/authopenid.load" do template "#{node['apache']['dir']}/mods-available/authopenid.load" do

View File

@@ -20,31 +20,11 @@
if platform_family?('debian') if platform_family?('debian')
package 'libapache2-mod-fastcgi' package 'libapache2-mod-fastcgi'
elsif platform_family?('rhel') elsif platform_family?('rhel')
%w[gcc make libtool httpd-devel apr-devel apr].each do |package| %w[gcc make libtool httpd-devel apr-devel apr mod_fcgid].each do |package|
yum_package package do yum_package package do
action :upgrade action :upgrade
end end
end end
src_filepath = "#{Chef::Config['file_cache_path']}/fastcgi.tar.gz"
remote_file 'download fastcgi source' do
source node['apache']['mod_fastcgi']['download_url']
path src_filepath
backup false
end
top_dir = node['apache']['lib_dir']
bash 'compile fastcgi source' do
notifies :run, 'execute[generate-module-list]', :immediately
not_if "test -f #{node['apache']['dir']}/mods-available/fastcgi.conf"
cwd ::File.dirname(src_filepath)
code <<-EOH
tar zxf #{::File.basename(src_filepath)} &&
cd mod_fastcgi-* &&
cp Makefile.AP2 Makefile &&
make top_dir=#{top_dir} && make install top_dir=#{top_dir}
EOH
end
end end
apache_module 'fastcgi' do apache_module 'fastcgi' do

View File

@@ -18,15 +18,31 @@
# #
if platform_family?('debian') if platform_family?('debian')
remote_file "#{Chef::Config[:file_cache_path]}/mod-pagespeed.deb" do if not node['local_repo'].nil? and not node['local_repo'].empty?
source node['apache2']['mod_pagespeed']['package_link'] package 'mod_pagespeed' do
mode '0644' package_name "mod_pagespeed-stable"
action :create_if_missing action :install
end end
else
if not node['proxy_url'].nil? and not node['proxy_url'].empty?
execute "download_mod-pagespeed.deb" do
command "wget -o mod-pagespeed.deb #{node['apache2']['mod_pagespeed']['package_link']}"
cwd Chef::Config['file_cache_path']
not_if { ::File.exists?("mod-pagespeed.deb") }
environment ({ 'http_proxy' => node['proxy_url'], 'https_proxy' => node['proxy_url'] })
end
else
remote_file "#{Chef::Config[:file_cache_path]}/mod-pagespeed.deb" do
source node['apache2']['mod_pagespeed']['package_link']
mode '0644'
action :create_if_missing
end
end
package 'mod_pagespeed' do package 'mod_pagespeed' do
source "#{Chef::Config[:file_cache_path]}/mod-pagespeed.deb" source "#{Chef::Config[:file_cache_path]}/mod-pagespeed.deb"
action :install action :install
end
end end
apache_module 'pagespeed' do apache_module 'pagespeed' do

View File

@@ -37,20 +37,4 @@ erlang_deps.each do |pkg|
end end
end end
bash 'install-erlang' do package 'erlang'
cwd Chef::Config[:file_cache_path]
code <<-EOH
tar -xzf otp_src_#{node['erlang']['source']['version']}.tar.gz
(cd otp_src_#{node['erlang']['source']['version']} && ./configure && make && make install)
EOH
action :nothing
not_if "erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell | grep #{node['erlang']['source']['version']}"
end
remote_file File.join(Chef::Config[:file_cache_path], "otp_src_#{node['erlang']['source']['version']}.tar.gz") do
source node['erlang']['source']['url']
owner 'root'
mode 0644
checksum node['erlang']['source']['checksum']
notifies :run, 'bash[install-erlang]', :immediately
end

View File

@@ -40,21 +40,4 @@ pkgs.each do |pkg|
package pkg package pkg
end end
# reduce line-noise-eyness package 'git'
remote_file "#{Chef::Config['file_cache_path']}/git-#{node['git']['version']}.tar.gz" do
source node['git']['url']
checksum node['git']['checksum']
mode '0644'
not_if "test -f #{Chef::Config['file_cache_path']}/git-#{node['git']['version']}.tar.gz"
end
# reduce line-noise-eyness
execute "Extracting and Building Git #{node['git']['version']} from Source" do
cwd Chef::Config['file_cache_path']
command <<-COMMAND
(mkdir git-#{node['git']['version']} && tar -zxf git-#{node['git']['version']}.tar.gz -C git-#{node['git']['version']} --strip-components 1)
(cd git-#{node['git']['version']} && make prefix=#{node['git']['prefix']} install)
COMMAND
creates "#{node['git']['prefix']}/bin/git"
not_if "git --version | grep #{node['git']['version']}"
end

View File

@@ -33,28 +33,7 @@ end
node.set['haproxy']['conf_dir'] = "#{node['haproxy']['source']['prefix']}/etc" node.set['haproxy']['conf_dir'] = "#{node['haproxy']['source']['prefix']}/etc"
remote_file "#{Chef::Config[:file_cache_path]}/haproxy-#{node['haproxy']['source']['version']}.tar.gz" do package 'haproxy'
source node['haproxy']['source']['url']
checksum node['haproxy']['source']['checksum']
action :create_if_missing
end
make_cmd = "make TARGET=#{node['haproxy']['source']['target_os']}"
make_cmd << " CPU=#{node['haproxy']['source']['target_cpu' ]}" unless node['haproxy']['source']['target_cpu'].empty?
make_cmd << " ARCH=#{node['haproxy']['source']['target_arch']}" unless node['haproxy']['source']['target_arch'].empty?
make_cmd << " USE_PCRE=1" if node['haproxy']['source']['use_pcre']
make_cmd << " USE_OPENSSL=1" if node['haproxy']['source']['use_openssl']
make_cmd << " USE_ZLIB=1" if node['haproxy']['source']['use_zlib']
bash "compile_haproxy" do
cwd Chef::Config[:file_cache_path]
code <<-EOH
tar xzf haproxy-#{node['haproxy']['source']['version']}.tar.gz
cd haproxy-#{node['haproxy']['source']['version']}
#{make_cmd} && make install PREFIX=#{node['haproxy']['source']['prefix']}
EOH
creates "#{node['haproxy']['source']['prefix']}/sbin/haproxy"
end
user "haproxy" do user "haproxy" do
comment "haproxy system account" comment "haproxy system account"

View File

@@ -44,15 +44,7 @@ node['mysql']['client']['packages'].each do |name|
resources("package[#{name}]").run_action(:install) resources("package[#{name}]").run_action(:install)
end end
case node['platform_family'] gem_package 'mysql' do
when 'debian' action :install
gem_package 'mysql' do version '2.9.1'
action :install
version '2.9.1'
end
when 'rhel'
chef_gem 'mysql' do
action :install
version '2.9.1'
end
end end

View File

@@ -32,16 +32,25 @@ when 'debian'
# installs the required setsid command -- should be there by default but just in case # installs the required setsid command -- should be there by default but just in case
package 'util-linux' package 'util-linux'
if node['rabbitmq']['use_distro_version'] if node['rabbitmq']['use_distro_version'] or (not node['local_repo'].nil? and not node['local_repo'].empty?)
package 'rabbitmq-server' do package 'rabbitmq-server' do
action :upgrade action :upgrade
end end
else else
# we need to download the package # we need to download the package
deb_package = "https://www.rabbitmq.com/releases/rabbitmq-server/v#{node['rabbitmq']['version']}/rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb" deb_package = "https://www.rabbitmq.com/releases/rabbitmq-server/v#{node['rabbitmq']['version']}/rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb"
remote_file "#{Chef::Config[:file_cache_path]}/rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb" do if not node['proxy_url'].nil? and not node['proxy_url'].empty?
source deb_package execute "download_mod-rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb" do
action :create_if_missing command "wget #{deb_package}"
cwd Chef::Config['file_cache_path']
not_if { ::File.exists?("rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb") }
environment ({ 'http_proxy' => node['proxy_url'], 'https_proxy' => node['proxy_url'] })
end
else
remote_file "#{Chef::Config[:file_cache_path]}/rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb" do
source deb_package
action :create_if_missing
end
end end
dpkg_package "#{Chef::Config[:file_cache_path]}/rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb" dpkg_package "#{Chef::Config[:file_cache_path]}/rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb"
end end
@@ -102,15 +111,25 @@ when 'rhel', 'fedora'
rpm_package "#{Chef::Config[:file_cache_path]}/esl-erlang-compat.rpm" rpm_package "#{Chef::Config[:file_cache_path]}/esl-erlang-compat.rpm"
end end
if node['rabbitmq']['use_distro_version'] if node['rabbitmq']['use_distro_version'] or (not node['local_repo'].nil? and not node['local_repo'].empty?)
package 'rabbitmq-server' package 'rabbitmq-server' do
action :upgrade
end
else else
# We need to download the rpm # We need to download the rpm
rpm_package = "https://www.rabbitmq.com/releases/rabbitmq-server/v#{node['rabbitmq']['version']}/rabbitmq-server-#{node['rabbitmq']['version']}-1.noarch.rpm" rpm_package = "https://www.rabbitmq.com/releases/rabbitmq-server/v#{node['rabbitmq']['version']}/rabbitmq-server-#{node['rabbitmq']['version']}-1.noarch.rpm"
if not node['proxy_url'].nil? and not node['proxy_url'].empty?
remote_file "#{Chef::Config[:file_cache_path]}/rabbitmq-server-#{node['rabbitmq']['version']}-1.noarch.rpm" do execute "download_mod-rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb" do
source rpm_package command "wget #{rpm_package}"
action :create_if_missing cwd Chef::Config['file_cache_path']
not_if { ::File.exists?("rabbitmq-server_#{node['rabbitmq']['version']}-1.noarch.rpm") }
environment ({ 'http_proxy' => node['proxy_url'], 'https_proxy' => node['proxy_url'] })
end
else
remote_file "#{Chef::Config[:file_cache_path]}/rabbitmq-server-#{node['rabbitmq']['version']}-1.noarch.rpm" do
source rpm_package
action :create_if_missing
end
end end
rpm_package "#{Chef::Config[:file_cache_path]}/rabbitmq-server-#{node['rabbitmq']['version']}-1.noarch.rpm" rpm_package "#{Chef::Config[:file_cache_path]}/rabbitmq-server-#{node['rabbitmq']['version']}-1.noarch.rpm"
end end

View File

@@ -10,7 +10,7 @@
grep -v GATEWAY /etc/sysconfig/network > /etc/sysconfig/network.cobbler grep -v GATEWAY /etc/sysconfig/network > /etc/sysconfig/network.cobbler
echo "GATEWAY=$gateway" >> /etc/sysconfig/network.cobbler echo "GATEWAY=$gateway" >> /etc/sysconfig/network.cobbler
rm -f /etc/sysconfig/network rm -f /etc/sysconfig/network
mv /etc/sysconfig/network.cobbler /etc/sysconfig/network mv -f /etc/sysconfig/network.cobbler /etc/sysconfig/network
#end if #end if
#if $hostname != "" #if $hostname != ""
@@ -18,7 +18,7 @@ mv /etc/sysconfig/network.cobbler /etc/sysconfig/network
grep -v HOSTNAME /etc/sysconfig/network > /etc/sysconfig/network.cobbler grep -v HOSTNAME /etc/sysconfig/network > /etc/sysconfig/network.cobbler
echo "HOSTNAME=$hostname" >> /etc/sysconfig/network.cobbler echo "HOSTNAME=$hostname" >> /etc/sysconfig/network.cobbler
rm -f /etc/sysconfig/network rm -f /etc/sysconfig/network
mv /etc/sysconfig/network.cobbler /etc/sysconfig/network mv -f /etc/sysconfig/network.cobbler /etc/sysconfig/network
/bin/hostname $hostname /bin/hostname $hostname
#end if #end if
@@ -414,7 +414,7 @@ used_logical_interfaces[$iname]=$iname
#if $iface_type in ("slave","bond_slave","bridge_slave","bonded_bridge_slave") #if $iface_type in ("slave","bond_slave","bridge_slave","bonded_bridge_slave")
#set $static = 1 #set $static = 1
#end if #end if
echo "DEVICE=$iname" > $devfile echo "DEVICE=$iname" > $devfile
echo "ONBOOT=yes" >> $devfile echo "ONBOOT=yes" >> $devfile
@@ -441,7 +441,7 @@ if [ -f "/etc/modprobe.conf" ] && [ ! -z "\${physical_interface}" ]; then
grep \$physical_interface /etc/modprobe.conf | sed "s/\${physical_interface}/$iname/" >> /etc/modprobe.conf.cobbler grep \$physical_interface /etc/modprobe.conf | sed "s/\${physical_interface}/$iname/" >> /etc/modprobe.conf.cobbler
grep -v \$physical_interface /etc/modprobe.conf >> /etc/modprobe.conf.new grep -v \$physical_interface /etc/modprobe.conf >> /etc/modprobe.conf.new
rm -f /etc/modprobe.conf rm -f /etc/modprobe.conf
mv /etc/modprobe.conf.new /etc/modprobe.conf mv -f /etc/modprobe.conf.new /etc/modprobe.conf
fi fi
#end if #end if
#end if #end if
@@ -560,7 +560,7 @@ for logical_interface in \${!logical_interface_mapping[@]}; do
grep \${physical_interface} /etc/modprobe.conf | sed "s/\${physical_interface}/\${logical_interface}/" >> /etc/modprobe.conf.cobbler grep \${physical_interface} /etc/modprobe.conf | sed "s/\${physical_interface}/\${logical_interface}/" >> /etc/modprobe.conf.cobbler
grep -v \${physical_interface} /etc/modprobe.conf >> /etc/modprobe.conf.new grep -v \${physical_interface} /etc/modprobe.conf >> /etc/modprobe.conf.new
rm -f /etc/modprobe.conf rm -f /etc/modprobe.conf
mv /etc/modprobe.conf.new /etc/modprobe.conf mv -f /etc/modprobe.conf.new /etc/modprobe.conf
fi fi
fi fi
done done
@@ -569,11 +569,11 @@ done
## the old files with the new ones in the working directory ## the old files with the new ones in the working directory
## This stops unneccesary (and time consuming) DHCP queries ## This stops unneccesary (and time consuming) DHCP queries
## during the network initialization ## during the network initialization
sed -i 's/ONBOOT=yes/ONBOOT=no/g' /etc/sysconfig/network-scripts/ifcfg-eth* sed -i 's/ONBOOT=yes/ONBOOT=no/g' /etc/sysconfig/network-scripts/ifcfg-*
## Move all staged files to their final location ## Move all staged files to their final location
rm -f /etc/sysconfig/network-scripts/ifcfg-* rm -f /etc/sysconfig/network-scripts/ifcfg-*
mv /etc/sysconfig/network-scripts/cobbler/* /etc/sysconfig/network-scripts/ mv -f /etc/sysconfig/network-scripts/cobbler/* /etc/sysconfig/network-scripts/
rm -r /etc/sysconfig/network-scripts/cobbler rm -r /etc/sysconfig/network-scripts/cobbler
if [ -f "/etc/modprobe.conf" ]; then if [ -f "/etc/modprobe.conf" ]; then
cat /etc/modprobe.conf.cobbler >> /etc/modprobe.conf cat /etc/modprobe.conf.cobbler >> /etc/modprobe.conf
@@ -584,6 +584,6 @@ if [ -f "/etc/udev/rules.d/\${udev_network_rule_filename}" ]; then
fi fi
if [ -f "/etc/udev/rules.d/\${udev_network_rule_filename}.new" ]; then if [ -f "/etc/udev/rules.d/\${udev_network_rule_filename}.new" ]; then
mv /etc/udev/rules.d/\${udev_network_rule_filename}.new /etc/udev/rules.d/\${udev_network_rule_filename} mv -f /etc/udev/rules.d/\${udev_network_rule_filename}.new /etc/udev/rules.d/\${udev_network_rule_filename}
fi fi
# End post_install_network_config generated code # End post_install_network_config generated code

View File

@@ -31,6 +31,13 @@ get_ifname() {
} }
#end raw #end raw
#set ikeys = $interfaces.keys() #set ikeys = $interfaces.keys()
#for $iname in $ikeys
#set $idata = $interfaces[$iname]
#set $management = $idata["management"]
#if $management
#set $management_nic = $iname
#end if
#end for
#for $iname in $ikeys #for $iname in $ikeys
#set $idata = $interfaces[$iname] #set $idata = $interfaces[$iname]
#set $mac = $idata["mac_address"] #set $mac = $idata["mac_address"]
@@ -41,9 +48,6 @@ get_ifname() {
#set $iface_type = $idata["interface_type"] #set $iface_type = $idata["interface_type"]
#set $iface_master = $idata["interface_master"] #set $iface_master = $idata["interface_master"]
#set $static_routes = $idata["static_routes"] #set $static_routes = $idata["static_routes"]
#if $management
#set $management_nic = $iname
#end if
#if $management_nic != '' #if $management_nic != ''
#if $iname != $management_nic #if $iname != $management_nic
#continue #continue

View File

@@ -30,7 +30,8 @@ distroverpkg=centos-release
EOF EOF
mkdir -p /root/repo_backup mkdir -p /root/repo_backup
mv /etc/yum.repos.d/* /root/repo_backup/ mv -f /etc/yum.repos.d/* /root/repo_backup/
#set profile_name = $getVar('profile_name','') #set profile_name = $getVar('profile_name','')
#set os_info = $profile_name.split('-') #set os_info = $profile_name.split('-')
#set osname = $os_info[0].lower() #set osname = $os_info[0].lower()
@@ -71,4 +72,9 @@ priority=1
proxy=_none_ proxy=_none_
skip_if_unavailable=1 skip_if_unavailable=1
EOF EOF
#if $getVar("local_repo_only","1") != "0"
yum -y update
rm -rf /etc/yum.repos.d/CentOS-*.repo
#end if
#end if #end if

View File

@@ -32,6 +32,11 @@ get_ifname() {
} }
#end raw #end raw
#set ikeys = $interfaces.keys() #set ikeys = $interfaces.keys()
#for $iname in $ikeys
#if $management
#set $management_nic = $iname
#end if
#end for
#for $iname in $ikeys #for $iname in $ikeys
#set $idata = $interfaces[$iname] #set $idata = $interfaces[$iname]
#set $mac = $idata["mac_address"] #set $mac = $idata["mac_address"]
@@ -42,9 +47,6 @@ get_ifname() {
#set $iface_type = $idata["interface_type"] #set $iface_type = $idata["interface_type"]
#set $iface_master = $idata["interface_master"] #set $iface_master = $idata["interface_master"]
#set $static_routes = $idata["static_routes"] #set $static_routes = $idata["static_routes"]
#if $management
#set $management_nic = $iname
#end if
#if $management_nic != '' #if $management_nic != ''
#if $iname != $management_nic #if $iname != $management_nic
#continue #continue