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']
when 'rhel', 'fedora'
remote_file "#{Chef::Config['file_cache_path']}/libopkele-2.0.4.tar.gz" do
source 'http://kin.klever.net/dist/libopkele-2.0.4.tar.gz'
mode '0644'
checksum '57a5bc753b7e80c5ece1e5968b2051b0ce7ed9ce4329d17122c61575a9ea7648'
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"
package 'libopkele'
package 'mod_auth_openid'
when 'debian'
package 'libapache2-mod-auth-openid'
end
template "#{node['apache']['dir']}/mods-available/authopenid.load" do

View File

@ -20,31 +20,11 @@
if platform_family?('debian')
package 'libapache2-mod-fastcgi'
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
action :upgrade
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
apache_module 'fastcgi' do

View File

@ -18,15 +18,31 @@
#
if platform_family?('debian')
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
if not node['local_repo'].nil? and not node['local_repo'].empty?
package 'mod_pagespeed' do
package_name "mod_pagespeed-stable"
action :install
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
source "#{Chef::Config[:file_cache_path]}/mod-pagespeed.deb"
action :install
package 'mod_pagespeed' do
source "#{Chef::Config[:file_cache_path]}/mod-pagespeed.deb"
action :install
end
end
apache_module 'pagespeed' do

View File

@ -37,20 +37,4 @@ erlang_deps.each do |pkg|
end
end
bash 'install-erlang' do
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
package 'erlang'

View File

@ -40,21 +40,4 @@ pkgs.each do |pkg|
package pkg
end
# reduce line-noise-eyness
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
package 'git'

View File

@ -33,28 +33,7 @@ end
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
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
package 'haproxy'
user "haproxy" do
comment "haproxy system account"

View File

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

View File

@ -32,16 +32,25 @@ when 'debian'
# installs the required setsid command -- should be there by default but just in case
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
action :upgrade
end
else
# 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"
remote_file "#{Chef::Config[:file_cache_path]}/rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb" do
source deb_package
action :create_if_missing
if not node['proxy_url'].nil? and not node['proxy_url'].empty?
execute "download_mod-rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb" do
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
dpkg_package "#{Chef::Config[:file_cache_path]}/rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb"
end
@ -102,15 +111,25 @@ when 'rhel', 'fedora'
rpm_package "#{Chef::Config[:file_cache_path]}/esl-erlang-compat.rpm"
end
if node['rabbitmq']['use_distro_version']
package 'rabbitmq-server'
if node['rabbitmq']['use_distro_version'] or (not node['local_repo'].nil? and not node['local_repo'].empty?)
package 'rabbitmq-server' do
action :upgrade
end
else
# 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"
remote_file "#{Chef::Config[:file_cache_path]}/rabbitmq-server-#{node['rabbitmq']['version']}-1.noarch.rpm" do
source rpm_package
action :create_if_missing
if not node['proxy_url'].nil? and not node['proxy_url'].empty?
execute "download_mod-rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb" do
command "wget #{rpm_package}"
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
rpm_package "#{Chef::Config[:file_cache_path]}/rabbitmq-server-#{node['rabbitmq']['version']}-1.noarch.rpm"
end

View File

@ -10,7 +10,7 @@
grep -v GATEWAY /etc/sysconfig/network > /etc/sysconfig/network.cobbler
echo "GATEWAY=$gateway" >> /etc/sysconfig/network.cobbler
rm -f /etc/sysconfig/network
mv /etc/sysconfig/network.cobbler /etc/sysconfig/network
mv -f /etc/sysconfig/network.cobbler /etc/sysconfig/network
#end if
#if $hostname != ""
@ -18,7 +18,7 @@ mv /etc/sysconfig/network.cobbler /etc/sysconfig/network
grep -v HOSTNAME /etc/sysconfig/network > /etc/sysconfig/network.cobbler
echo "HOSTNAME=$hostname" >> /etc/sysconfig/network.cobbler
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
#end if
@ -414,7 +414,7 @@ used_logical_interfaces[$iname]=$iname
#if $iface_type in ("slave","bond_slave","bridge_slave","bonded_bridge_slave")
#set $static = 1
#end if
#end if
echo "DEVICE=$iname" > $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 -v \$physical_interface /etc/modprobe.conf >> /etc/modprobe.conf.new
rm -f /etc/modprobe.conf
mv /etc/modprobe.conf.new /etc/modprobe.conf
mv -f /etc/modprobe.conf.new /etc/modprobe.conf
fi
#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 -v \${physical_interface} /etc/modprobe.conf >> /etc/modprobe.conf.new
rm -f /etc/modprobe.conf
mv /etc/modprobe.conf.new /etc/modprobe.conf
mv -f /etc/modprobe.conf.new /etc/modprobe.conf
fi
fi
done
@ -569,11 +569,11 @@ done
## the old files with the new ones in the working directory
## This stops unneccesary (and time consuming) DHCP queries
## 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
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
if [ -f "/etc/modprobe.conf" ]; then
cat /etc/modprobe.conf.cobbler >> /etc/modprobe.conf
@ -584,6 +584,6 @@ if [ -f "/etc/udev/rules.d/\${udev_network_rule_filename}" ]; then
fi
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
# End post_install_network_config generated code

View File

@ -31,6 +31,13 @@ get_ifname() {
}
#end raw
#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
#set $idata = $interfaces[$iname]
#set $mac = $idata["mac_address"]
@ -41,9 +48,6 @@ get_ifname() {
#set $iface_type = $idata["interface_type"]
#set $iface_master = $idata["interface_master"]
#set $static_routes = $idata["static_routes"]
#if $management
#set $management_nic = $iname
#end if
#if $management_nic != ''
#if $iname != $management_nic
#continue

View File

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

View File

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