add preseed support for ubuntu

Change-Id: Ifa4f7af2fe072585e611667c35d0d71830f410c5
This commit is contained in:
xiaodongwang 2014-05-14 22:46:02 -07:00
parent 47550ababc
commit 71883bcd4c
14 changed files with 655 additions and 201 deletions

View File

@ -85,27 +85,33 @@ class OsInstallerCheck(base.BaseCheck):
path_map = { path_map = {
'match_kickstart': ( 'match_kickstart': (
'/var/lib/cobbler/kickstarts/', '/var/lib/cobbler/kickstarts/',
['default.ks', ] ['default.ks', 'default.seed']
), ),
'match_snippets': ( 'match_snippets': (
'/var/lib/cobbler/snippets/', '/var/lib/cobbler/snippets/',
[ [
'chef',
'chef-validator.pem',
'client.rb',
'kickstart_done', 'kickstart_done',
'kickstart_start', 'kickstart_start',
'network_config', 'kickstart_pre_partition_disks',
'ntp.conf', 'kickstart_partition_disks',
'partition_disks', 'kickstart_pre_anamon',
'partition_select', 'kickstart_post_anamon',
'post_anamon', 'kickstart_pre_install_network_config',
'post_install_network_config', 'kickstart_network_config',
'pre_anamon', 'kickstart_post_install_network_config',
'pre_install_network_config', 'kickstart_chef',
'rsyslogchef', 'kickstart_ntp',
'rsyslogconf', 'kickstart_yum_repo_config',
'yum.conf', 'preseed_pre_partition_disks',
'preseed_partition_disks',
'preseed_pre_anamon',
'preseed_post_anamon',
'preseed_pre_install_network_config',
'preseed_network_config',
'preseed_post_install_network_config',
'preseed_chef',
'preseed_ntp',
'preseed_apt_repo_config',
] ]
), ),
'match_ks_mirror': ( 'match_ks_mirror': (
@ -114,7 +120,7 @@ class OsInstallerCheck(base.BaseCheck):
), ),
'match_repo_mirror': ( 'match_repo_mirror': (
'/var/www/cobbler/', '/var/www/cobbler/',
['repo_mirror/ppa_repo'] ['repo_mirror']
), ),
'match_iso': ( 'match_iso': (
'/var/lib/cobbler/', '/var/lib/cobbler/',

View File

@ -19,7 +19,6 @@
import fnmatch import fnmatch
import functools import functools
import logging import logging
import traceback
from compass.config_management.installers import package_installer from compass.config_management.installers import package_installer
from compass.config_management.utils.config_translator import ConfigTranslator from compass.config_management.utils.config_translator import ConfigTranslator
@ -220,11 +219,10 @@ class Installer(package_installer.Installer):
client.delete() client.delete()
logging.debug( logging.debug(
'delete %s for host %s ', target_system, node_name) 'delete %s for host %s ', target_system, node_name)
except Exception: except Exception as error:
logging.debug( logging.debug(
'failed to delete %s for host %s: %s', 'failed to delete %s for host %s: %s',
target_system, node_name, target_system, node_name, error)
''.join(traceback.format_stack()))
else: else:
node.run_list = [] node.run_list = []
@ -355,11 +353,10 @@ class Installer(package_installer.Installer):
logging.debug( logging.debug(
'databag item %s is removed from target_system %s', 'databag item %s is removed from target_system %s',
bag_item_name, target_system) bag_item_name, target_system)
except Exception: except Exception as error:
logging.debug( logging.debug(
'no databag item %s to delete from target_system %s: %s', 'no databag item %s to delete from target_system %s: %s',
bag_item_name, target_system, bag_item_name, target_system, error)
''.join(traceback.format_stack()))
del databag_items[bag_item_name] del databag_items[bag_item_name]

View File

@ -29,6 +29,148 @@ from compass.log_analyzor.line_matcher import LineMatcher
# TODO(weidong): reconsider intialization method for the following. # TODO(weidong): reconsider intialization method for the following.
OS_INSTALLER_CONFIGURATIONS = { OS_INSTALLER_CONFIGURATIONS = {
'Ubuntu': AdapterItemMatcher(
file_matchers=[
FileMatcher(
filename='syslog',
min_progress=0.0,
max_progress=1.0,
line_matchers={
'start': LineMatcher(
pattern=r'.*',
progress=.05,
message_template='start installing',
unmatch_nextline_next_matcher_name='start',
match_nextline_next_matcher_name='ethdetect'
),
'ethdetect': LineMatcher(
pattern=r'Menu.*item.*\'ethdetect\'.*selected',
progress=.1,
message_template='ethdetect selected',
unmatch_nextline_next_matcher_name='ethdetect',
match_nextline_next_matcher_name='netcfg'
),
'netcfg': LineMatcher(
pattern=r'Menu.*item.*\'netcfg\'.*selected',
progress=.12,
message_template='netcfg selected',
unmatch_nextline_next_matcher_name='netcfg',
match_nextline_next_matcher_name='network-preseed'
),
'network-preseed': LineMatcher(
pattern=r'Menu.*item.*\'network-preseed\'.*selected',
progress=.15,
message_template='network-preseed selected',
unmatch_nextline_next_matcher_name='network-preseed',
match_nextline_next_matcher_name='localechooser'
),
'localechoose': LineMatcher(
pattern=r'Menu.*item.*\'localechooser\'.*selected',
progress=.18,
message_template='localechooser selected',
unmatch_nextline_next_matcher_name='localechooser',
match_nextline_next_matcher_name='download-installer'
),
'download-installer': LineMatcher(
pattern=(
r'Menu.*item.*\'download-installer\'.*selected'
),
progress=.2,
message_template='download installer selected',
unmatch_nextline_next_matcher_name=(
'download-installer'),
match_nextline_next_matcher_name='clock-setup'
),
'clock-setup': LineMatcher(
pattern=r'Menu.*item.*\'clock-setup\'.*selected',
progress=.3,
message_template='clock-setup selected',
unmatch_nextline_next_matcher_name='clock-setup',
match_nextline_next_matcher_name='disk-detect'
),
'disk-detect': LineMatcher(
pattern=r'Menu.*item.*\'disk-detect\'.*selected',
progress=.32,
message_template='disk-detect selected',
unmatch_nextline_next_matcher_name='disk-detect',
match_nextline_next_matcher_name='partman-base'
),
'partman-base': LineMatcher(
pattern=r'Menu.*item.*\'partman-base\'.*selected',
progress=.35,
message_template='partman-base selected',
unmatch_nextline_next_matcher_name='partman-base',
match_nextline_next_matcher_name='live-installer'
),
'live-installer': LineMatcher(
pattern=r'Menu.*item.*\'live-installer\'.*selected',
progress=.45,
message_template='live-installer selected',
unmatch_nextline_next_matcher_name='live-installer',
match_nextline_next_matcher_name='pkgsel'
),
'pkgsel': LineMatcher(
pattern=r'Menu.*item.*\'pkgsel\'.*selected',
progress=.5,
message_template='pkgsel selected',
unmatch_nextline_next_matcher_name='pkgsel',
match_nextline_next_matcher_name='grub-installer'
),
'grub-installer': LineMatcher(
pattern=r'Menu.*item.*\'grub-installer\'.*selected',
progress=.9,
message_template='grub-installer selected',
unmatch_nextline_next_matcher_name='grub-installer',
match_nextline_next_matcher_name='finish-install'
),
'finish-install': LineMatcher(
pattern=r'Menu.*item.*\'finish-install\'.*selected',
progress=.95,
message_template='finish-install selected',
unmatch_nextline_next_matcher_name='finish-install',
match_nextline_next_matcher_name='finish-install-done'
),
'finish-install-done': LineMatcher(
pattern=r'Running.*finish-install.d/.*save-logs',
progress=1.0,
message_template='finish-install is done',
unmatch_nextline_next_matcher_name=(
'finish-install-done'
),
match_nextline_next_matcher_name='exit'
),
}
),
FileMatcher(
filename='status',
min_progress=.2,
max_progress=.3,
line_matchers={
'start': LineMatcher(
pattern=r'Package: (?P<package>.*)',
progress=IncrementalProgress(0.0, 0.99, 0.05),
message_template='Installing udeb %(package)s',
unmatch_nextline_next_matcher_name='start',
match_nextline_next_matcher_name='start'
)
}
),
FileMatcher(
filename='initial-status',
min_progress=.5,
max_progress=.9,
line_matchers={
'start': LineMatcher(
pattern=r'Package: (?P<package>.*)',
progress=IncrementalProgress(0.0, 0.99, 0.01),
message_template='Installing deb %(package)s',
unmatch_nextline_next_matcher_name='start',
match_nextline_next_matcher_name='start'
)
}
),
]
),
'CentOS': AdapterItemMatcher( 'CentOS': AdapterItemMatcher(
file_matchers=[ file_matchers=[
FileMatcher( FileMatcher(
@ -257,7 +399,21 @@ ADAPTER_CONFIGURATIONS = [
item_matcher=PACKAGE_INSTALLER_CONFIGURATIONS['openstack'], item_matcher=PACKAGE_INSTALLER_CONFIGURATIONS['openstack'],
min_progress=0.6, min_progress=0.6,
max_progress=1.0) max_progress=1.0)
) ),
AdapterMatcher(
os_matcher=OSMatcher(
os_installer_name='cobbler',
os_pattern='Ubuntu.*',
item_matcher=OS_INSTALLER_CONFIGURATIONS['Ubuntu'],
min_progress=0.0,
max_progress=0.6),
package_matcher=PackageMatcher(
package_installer_name='chef',
target_system='openstack',
item_matcher=PACKAGE_INSTALLER_CONFIGURATIONS['openstack'],
min_progress=0.6,
max_progress=1.0)
),
] ]
@ -270,6 +426,9 @@ def _get_adapter_matcher(
if configuration.match(os_installer, os_name, if configuration.match(os_installer, os_name,
package_installer, target_system): package_installer, target_system):
return configuration return configuration
else:
logging.debug('configuration %s does not match %s and %s',
configuration, os_name, target_system)
logging.error('No configuration found with os installer %s os %s ' logging.error('No configuration found with os installer %s os %s '
'package_installer %s, target_system %s', 'package_installer %s, target_system %s',

View File

@ -16,6 +16,8 @@
.. moduleauthor:: Xiaodong Wang <xiaodongwang@huawei.com> .. moduleauthor:: Xiaodong Wang <xiaodongwang@huawei.com>
""" """
import logging
from celery.signals import setup_logging from celery.signals import setup_logging
from compass.actions import clean_deployment from compass.actions import clean_deployment
@ -51,7 +53,10 @@ def pollswitch(ip_addr, req_obj='mac', oper='SCAN'):
:param oper: the operation to query the switch (SCAN, GET, SET). :param oper: the operation to query the switch (SCAN, GET, SET).
:type oper: str :type oper: str
""" """
try:
poll_switch.poll_switch(ip_addr, req_obj=req_obj, oper=oper) poll_switch.poll_switch(ip_addr, req_obj=req_obj, oper=oper)
except Exception as error:
logging.exception(error)
@celery.task(name='compass.tasks.deploy') @celery.task(name='compass.tasks.deploy')
@ -61,7 +66,10 @@ def deploy_clusters(cluster_hosts):
:param cluster_hosts: the cluster and hosts of each cluster to deploy. :param cluster_hosts: the cluster and hosts of each cluster to deploy.
:type cluster_hosts: dict of int to list of int :type cluster_hosts: dict of int to list of int
""" """
try:
deploy.deploy(cluster_hosts) deploy.deploy(cluster_hosts)
except Exception as error:
logging.exception(error)
@celery.task(name='compass.tasks.reinstall') @celery.task(name='compass.tasks.reinstall')
@ -71,7 +79,10 @@ def reinstall_clusters(cluster_hosts):
:param cluster_hosts: the cluster and hosts of each cluster to reinstall. :param cluster_hosts: the cluster and hosts of each cluster to reinstall.
:type cluster_hosts: dict of int to list of int :type cluster_hosts: dict of int to list of int
""" """
try:
reinstall.reinstall(cluster_hosts) reinstall.reinstall(cluster_hosts)
except Exception as error:
logging.exception(error)
@celery.task(name='compass.tasks.clean_deployment') @celery.task(name='compass.tasks.clean_deployment')
@ -81,7 +92,10 @@ def clean_clusters_deployment(cluster_hosts):
:param cluster_hosts: the cluster and hosts of each cluster to clean. :param cluster_hosts: the cluster and hosts of each cluster to clean.
:type cluster_hosts: dict of int to list of int :type cluster_hosts: dict of int to list of int
""" """
try:
clean_deployment.clean_deployment(cluster_hosts) clean_deployment.clean_deployment(cluster_hosts)
except Exception as error:
logging.exception(error)
@celery.task(name='compass.tasks.clean_installing_progress') @celery.task(name='compass.tasks.clean_installing_progress')
@ -91,7 +105,10 @@ def clean_clusters_installing_progress(cluster_hosts):
:param cluster_hosts: the cluster and hosts of each cluster to clean. :param cluster_hosts: the cluster and hosts of each cluster to clean.
:type cluster_hosts: dict of int to list of int :type cluster_hosts: dict of int to list of int
""" """
try:
clean_installing_progress.clean_installing_progress(cluster_hosts) clean_installing_progress.clean_installing_progress(cluster_hosts)
except Exception as error:
logging.exception(error)
@celery.task(name='compass.tasks.update_progress') @celery.task(name='compass.tasks.update_progress')
@ -101,4 +118,7 @@ def update_clusters_progress(cluster_hosts):
:param cluster_hosts: the cluster and hosts of each cluster to update. :param cluster_hosts: the cluster and hosts of each cluster to update.
:type cluster_hosts: dict of int to list of int :type cluster_hosts: dict of int to list of int
""" """
try:
update_progress.update_progress(cluster_hosts) update_progress.update_progress(cluster_hosts)
except Exception as error:
logging.exception(error)

View File

@ -5,3 +5,5 @@ CELERY_RESULT_BACKEND ="amqp://"
BROKER_URL = "amqp://guest:guest@localhost:5672//" BROKER_URL = "amqp://guest:guest@localhost:5672//"
CELERY_IMPORTS=("compass.tasks.tasks",) CELERY_IMPORTS=("compass.tasks.tasks",)
CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml']
C_FORCE_ROOT = 1

View File

@ -6,7 +6,7 @@ sudo mkdir -p /root/backup/chef
sudo rpm -q chef-server sudo rpm -q chef-server
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
download $CHEF_SRV chef-server install download $CHEF_SRV chef-server install || exit $?
else else
echo "chef-server has already installed" echo "chef-server has already installed"
fi fi
@ -47,7 +47,7 @@ fi
# configure chef client and knife # configure chef client and knife
rpm -q chef rpm -q chef
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
download $CHEF_CLIENT chef-client install download $CHEF_CLIENT `basename $CHEF_CLIENT` install || exit $?
else else
echo "chef has already installed" echo "chef has already installed"
fi fi

View File

@ -2,7 +2,7 @@
# #
echo "Installing cobbler related packages" echo "Installing cobbler related packages"
sudo yum -y install cobbler cobbler-web createrepo mkisofs python-cheetah python-simplejson python-urlgrabber PyYAML Django cman debmirror pykickstart sudo yum -y install cobbler cobbler-web createrepo mkisofs python-cheetah python-simplejson python-urlgrabber PyYAML Django cman debmirror pykickstart reprepro
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
echo "failed to install cobbler related packages" echo "failed to install cobbler related packages"
exit 1 exit 1
@ -95,15 +95,16 @@ sudo cp -rn /var/lib/cobbler/kickstarts/ /root/backup/cobbler/
sudo cp -rn /var/lib/cobbler/triggers /root/backup/cobbler/ sudo cp -rn /var/lib/cobbler/triggers /root/backup/cobbler/
sudo rm -rf /var/lib/cobbler/snippets/* sudo rm -rf /var/lib/cobbler/snippets/*
sudo cp -rf $ADAPTERS_HOME/cobbler/snippets/* /var/lib/cobbler/snippets/ sudo cp -rf $ADAPTERS_HOME/cobbler/snippets/* /var/lib/cobbler/snippets/
sudo cp -rf $HOME/.ssh/id_rsa.pub /var/lib/cobbler/snippets/
sudo cp -rf $ADAPTERS_HOME/cobbler/triggers/* /var/lib/cobbler/triggers/ sudo cp -rf $ADAPTERS_HOME/cobbler/triggers/* /var/lib/cobbler/triggers/
sudo chmod 777 /var/lib/cobbler/snippets sudo chmod 777 /var/lib/cobbler/snippets
sudo chmod -R 666 /var/lib/cobbler/snippets/* sudo chmod -R 666 /var/lib/cobbler/snippets/*
sudo chmod -R 755 /var/lib/cobbler/triggers sudo chmod -R 755 /var/lib/cobbler/triggers
sudo sed -i "s/# \$compass_ip \$compass_hostname/$ipaddr $HOSTNAME/g" /var/lib/cobbler/snippets/hosts
sudo rm -f /var/lib/cobbler/kickstarts/default.ks sudo rm -f /var/lib/cobbler/kickstarts/default.ks
sudo rm -f /var/lib/cobbler/kickstarts/default.seed
sudo cp -rf $ADAPTERS_HOME/cobbler/kickstarts/default.ks /var/lib/cobbler/kickstarts/ sudo cp -rf $ADAPTERS_HOME/cobbler/kickstarts/default.ks /var/lib/cobbler/kickstarts/
sudo cp -rf $ADAPTERS_HOME/cobbler/kickstarts/default.seed /var/lib/cobbler/kickstarts/
sudo chmod 666 /var/lib/cobbler/kickstarts/default.ks sudo chmod 666 /var/lib/cobbler/kickstarts/default.ks
sudo chmod 666 /var/lib/cobbler/kickstarts/default.seed
sudo mkdir /var/www/cblr_ks sudo mkdir /var/www/cblr_ks
sudo chmod 755 /var/www/cblr_ks sudo chmod 755 /var/www/cblr_ks
sudo cp -rf $ADAPTERS_HOME/cobbler/conf/cobbler.conf /etc/httpd/conf.d/ sudo cp -rf $ADAPTERS_HOME/cobbler/conf/cobbler.conf /etc/httpd/conf.d/
@ -120,6 +121,8 @@ sudo service iptables status
if [[ "$?" == "0" ]]; then if [[ "$?" == "0" ]]; then
echo "iptables is running" echo "iptables is running"
exit 1 exit 1
else
echo "iptables is already stopped"
fi fi
echo "disable selinux temporarily" echo "disable selinux temporarily"
@ -130,7 +133,6 @@ sudo service cobblerd restart
sudo cobbler get-loaders sudo cobbler get-loaders
sudo cobbler sync sudo cobbler sync
sudo service xinetd restart sudo service xinetd restart
sudo cobbler check
echo "Checking if httpd is running" echo "Checking if httpd is running"
sudo service httpd status sudo service httpd status
@ -169,6 +171,7 @@ else
fi fi
echo "Checking if cobblerd is running" echo "Checking if cobblerd is running"
sudo service cobblerd status
if [[ "$?" == "0" ]]; then if [[ "$?" == "0" ]]; then
echo "cobblerd is running." echo "cobblerd is running."
else else
@ -176,130 +179,276 @@ else
exit 1 exit 1
fi fi
# create repo # create centos repo
sudo mkdir -p /var/lib/cobbler/repo_mirror/ppa_repo sudo mkdir -p /var/lib/cobbler/repo_mirror/centos_ppa_repo
found_ppa_repo=0 found_centos_ppa_repo=0
for repo in $(cobbler repo list); do for repo in $(cobbler repo list); do
if [ "$repo" == "ppa_repo" ]; then if [ "$repo" == "centos_ppa_repo" ]; then
found_ppa_repo=1 found_centos_ppa_repo=1
fi fi
done done
if [ "$found_ppa_repo" == "0" ]; then if [ "$found_centos_ppa_repo" == "0" ]; then
sudo cobbler repo add --mirror=/var/lib/cobbler/repo_mirror/ppa_repo --name=ppa_repo --mirror-locally=Y sudo cobbler repo add --mirror=/var/lib/cobbler/repo_mirror/centos_ppa_repo --name=centos_ppa_repo --mirror-locally=Y --arch=${CENTOS_IMAGE_ARCH}
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
echo "failed to add ppa_repo" echo "failed to add centos_ppa_repo"
exit 1 exit 1
else else
echo "ppa_repo is added" echo "centos_ppa_repo is added"
fi fi
else else
echo "repo ppa_repo has already existed." echo "repo centos_ppa_repo has already existed."
fi fi
# download packages # download packages
cd /var/lib/cobbler/repo_mirror/ppa_repo/ cd /var/lib/cobbler/repo_mirror/centos_ppa_repo/
ppa_repo_packages="ntp-4.2.6p5-1.el6.${IMAGE_TYPE,,}.$IMAGE_ARCH.rpm centos_ppa_repo_packages="
openssh-clients-5.3p1-94.el6.${IMAGE_ARCH}.rpm ntp-4.2.6p5-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_TYPE,,}.${CENTOS_IMAGE_ARCH}.rpm
iproute-2.6.32-31.el6.${IMAGE_ARCH}.rpm openssh-clients-5.3p1-94.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
wget-1.12-1.8.el6.${IMAGE_ARCH}.rpm iproute-2.6.32-31.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
ntpdate-4.2.6p5-1.el6.${IMAGE_TYPE,,}.${IMAGE_ARCH}.rpm" wget-1.12-1.8.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
for f in $ppa_repo_packages ntpdate-4.2.6p5-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_TYPE,,}.${CENTOS_IMAGE_ARCH}.rpm"
do for f in $centos_ppa_repo_packages; do
download ftp://rpmfind.net/linux/${IMAGE_TYPE,,}/${IMAGE_VERSION_MAJOR}/os/${IMAGE_ARCH}/Packages/$f $f copy /var/lib/cobbler/repo_mirror/ppa_repo/ download ftp://rpmfind.net/linux/${CENTOS_IMAGE_TYPE,,}/${CENTOS_IMAGE_VERSION_MAJOR}/os/${CENTOS_IMAGE_ARCH}/Packages/$f $f copy /var/lib/cobbler/repo_mirror/centos_ppa_repo/ || exit $?
done done
ppa_repo_rsyslog_packages="json-c-0.10-2.el6.$IMAGE_ARCH.rpm centos_ppa_repo_rsyslog_packages="
libestr-0.1.9-1.el6.$IMAGE_ARCH.rpm json-c-0.10-2.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
libgt-0.3.11-1.el6.$IMAGE_ARCH.rpm libestr-0.1.9-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
liblogging-1.0.4-1.el6.$IMAGE_ARCH.rpm libgt-0.3.11-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
rsyslog-7.6.3-1.el6.$IMAGE_ARCH.rpm" liblogging-1.0.4-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
for f in $ppa_repo_rsyslog_packages rsyslog-7.6.3-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm"
do for f in $centos_ppa_repo_rsyslog_packages; do
download http://rpms.adiscon.com/v7-stable/epel-6/${IMAGE_ARCH}/RPMS/$f $f copy /var/lib/cobbler/repo_mirror/ppa_repo/ download http://rpms.adiscon.com/v7-stable/epel-{CENTOS_IMAGE_VERSION_MAJOR}/${CENTOS_IMAGE_ARCH}/RPMS/$f $f copy /var/lib/cobbler/repo_mirror/centos_ppa_repo/ || exit $?
done done
# download chef client for ppa repo # download chef client for centos ppa repo
download $CHEF_CLIENT `basename $CHEF_CLIENT` copy /var/lib/cobbler/repo_mirror/ppa_repo/ download $CENTOS_CHEF_CLIENT `basename $CENTOS_CHEF_CLIENT` copy /var/lib/cobbler/repo_mirror/centos_ppa_repo/
# create centos repo
cd .. cd ..
sudo createrepo ppa_repo sudo createrepo centos_ppa_repo
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
echo "failed to createrepo ppa_repo" echo "failed to createrepo centos_ppa_repo"
exit 1 exit 1
else else
echo "ppa_repo is created" echo "centos_ppa_repo is created"
fi
# create ubuntu repo
sudo mkdir -p /var/lib/cobbler/repo_mirror/ubuntu_ppa_repo
found_ubuntu_ppa_repo=0
for repo in $(cobbler repo list); do
if [ "$repo" == "ubuntu_ppa_repo" ]; then
found_ubuntu_ppa_repo=1
fi
done
if [ "$found_ubuntu_ppa_repo" == "0" ]; then
sudo cobbler repo add --mirror=/var/lib/cobbler/repo_mirror/ubuntu_ppa_repo --name=ubuntu_ppa_repo --mirror-locally=Y --arch=${UBUNTU_IMAGE_ARCH} --apt-dists=ppa --apt-components=main
if [[ "$?" != "0" ]]; then
echo "failed to add ubuntu_ppa_repo"
exit 1
else
echo "ubuntu_ppa_repo is added"
fi
else
echo "repo ubuntu_ppa_repo has already existed."
fi
cd /var/lib/cobbler/repo_mirror/ubuntu_ppa_repo/
if [ ! -e /var/lib/cobbler/repo_mirror/ubuntu_ppa_repo/conf/distributions ]; then
echo "create ubuntu ppa repo distribution"
mkdir -p /var/lib/cobbler/repo_mirror/ubuntu_ppa_repo/conf
cat << EOF > /var/lib/cobbler/repo_mirror/ubuntu_ppa_repo/conf/distributions
Origin: ppa
Label: ppa_repo
Suite: stable
Codename: ppa
Version: 0.1
Architectures: i386 amd64 source
Components: main
Description: ppa repo
EOF
chmod 644 /var/lib/cobbler/repo_mirror/ubuntu_ppa_repo/conf/distributions
else
echo "ubuntu ppa repo distribution file exists."
fi
# download chef client for ubuntu ppa repo
download $UBUNTU_CHEF_CLIENT `basename $UBUNTU_CHEF_CLIENT` copy /var/lib/cobbler/repo_mirror/ubuntu_ppa_repo/ || exit $?
cd ..
find ubuntu_ppa_repo -name \*.deb -exec reprepro -Vb ubuntu_ppa_repo includedeb ppa {} \;
if [ "$?" != "0" ]; then
echo "failed to create ubuntu_ppa_repo"
exit 1
else
echo "ubuntu_ppa_repo is created"
fi fi
sudo cobbler reposync sudo cobbler reposync
if [[ "$?" != "0" ]]; then
echo "cobbler reposync failed"
exit 1
else
echo "cobbler repos are synced"
fi
# import cobbler distro # import cobbler distro
sudo mkdir -p /var/lib/cobbler/iso sudo mkdir -p /var/lib/cobbler/iso
download "$IMAGE_SOURCE" ${IMAGE_NAME}-${IMAGE_ARCH}.iso copy /var/lib/cobbler/iso/ download "$CENTOS_IMAGE_SOURCE" ${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}.iso copy /var/lib/cobbler/iso/ || exit $?
sudo mkdir -p /mnt/${IMAGE_NAME}-${IMAGE_ARCH} sudo mkdir -p /mnt/${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}
if [ $(mount | grep -c "/mnt/${IMAGE_NAME}-${IMAGE_ARCH} ") -eq 0 ]; then if [ $(mount | grep -c "/mnt/${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH} ") -eq 0 ]; then
sudo mount -o loop /var/lib/cobbler/iso/${IMAGE_NAME}-${IMAGE_ARCH}.iso /mnt/${IMAGE_NAME}-${IMAGE_ARCH} sudo mount -o loop /var/lib/cobbler/iso/${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}.iso /mnt/${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
echo "failed to mount image /mnt/${IMAGE_NAME}-${IMAGE_ARCH}" echo "failed to mount image /mnt/${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}"
exit 1 exit 1
else else
echo "/mnt/${IMAGE_NAME}-${IMAGE_ARCH} is mounted" echo "/mnt/${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH} is mounted"
fi fi
else else
echo "/mnt/${IMAGE_NAME}-${IMAGE_ARCH} has already mounted" echo "/mnt/${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH} has already mounted"
fi
download "$UBUNTU_IMAGE_SOURCE" ${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH}.iso copy /var/lib/cobbler/iso/ || exit $?
sudo mkdir -p /mnt/${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH}
if [ $(mount | grep -c "/mnt/${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH} ") -eq 0 ]; then
sudo mount -o loop /var/lib/cobbler/iso/${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH}.iso /mnt/${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH}
if [[ "$?" != "0" ]]; then
echo "failed to mount image /mnt/${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH}"
exit 1
else
echo "/mnt/${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH} is mounted"
fi
else
echo "/mnt/${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH} has already mounted"
fi fi
# add distro # add distro
found_distro=0 found_centos_distro=0
for distro in $(cobbler distro list); do for distro in $(cobbler distro list); do
if [ "$distro" == "${IMAGE_NAME}-${IMAGE_ARCH}" ]; then if [ "$distro" == "${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}" ]; then
found_distro=1 found_centos_distro=1
fi fi
done done
if [ "$found_distro" == "0" ]; then if [ "$found_centos_distro" == "0" ]; then
sudo cobbler import --path=/mnt/${IMAGE_NAME}-${IMAGE_ARCH} --name=${IMAGE_NAME} --arch=${IMAGE_ARCH} --kickstart=/var/lib/cobbler/kickstarts/default.ks --breed=redhat sudo cobbler import --path=/mnt/${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH} --name=${CENTOS_IMAGE_NAME} --arch=${CENTOS_IMAGE_ARCH} --kickstart=/var/lib/cobbler/kickstarts/default.ks --breed=redhat
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
echo "failed to import /mnt/${IMAGE_NAME}-${IMAGE_ARCH}" echo "failed to import /mnt/${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}"
exit 1 exit 1
else else
echo "/mnt/${IMAGE_NAME}-${IMAGE_ARCH} is imported" echo "/mnt/${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH} is imported"
fi fi
else else
echo "distro ${IMAGE_NAME}-${IMAGE_ARCH} has already existed" echo "distro ${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH} has already existed"
sudo cobbler distro edit --name=${IMAGE_NAME}-${IMAGE_ARCH} --arch=${IMAGE_ARCH} --breed=redhat sudo cobbler distro edit --name=${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH} --arch=${CENTOS_IMAGE_ARCH} --breed=redhat
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
echo "failed to edit distro ${IMAGE_NAME}-${IMAGE_ARCH}" echo "failed to edit distro ${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}"
exit 1 exit 1
else else
echo "distro ${IMAGE_NAME}-${IMAGE_ARCH} is updated" echo "distro ${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH} is updated"
fi
fi
found_ubuntu_distro=0
for distro in $(cobbler distro list); do
if [ "$distro" == "${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH}" ]; then
found_ubuntu_distro=1
fi
done
if [ "$found_ubuntu_distro" == "0" ]; then
sudo cobbler import --path=/mnt/${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH} --name=${UBUNTU_IMAGE_NAME} --arch=${UBUNTU_IMAGE_ARCH} --kickstart=/var/lib/cobbler/kickstarts/default.seed --breed=ubuntu
if [[ "$?" != "0" ]]; then
echo "failed to import /mnt/${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH}"
exit 1
else
echo "/mnt/${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH} is imported"
fi
else
echo "distro ${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH} has already existed"
sudo cobbler distro edit --name=${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH} --arch=${UBUNTU_IMAGE_ARCH} --breed=ubuntu
if [[ "$?" != "0" ]]; then
echo "failed to edit distro ${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH}"
exit 1
else
echo "distro ${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH} is updated"
fi fi
fi fi
# add profile # add profile
found_profile=0 centos_found_profile=0
for profile in $(cobbler profile list); do for profile in $(cobbler profile list); do
if [ "$profile" == "${IMAGE_NAME}-${IMAGE_ARCH}" ]; then if [ "$profile" == "${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}" ]; then
found_profile=1 centos_found_profile=1
fi fi
done done
if [ "$found_profile" == "0" ]; then if [ "$centos_found_profile" == "0" ]; then
sudo cobbler profile add --name="${IMAGE_NAME}-${IMAGE_ARCH}" --repo=ppa_repo --distro="${IMAGE_NAME}-${IMAGE_ARCH}" --ksmeta="tree=http://$ipaddr/cobbler/ks_mirror/${IMAGE_NAME}-${IMAGE_ARCH}" --kickstart=/var/lib/cobbler/kickstarts/default.ks sudo cobbler profile add --name="${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}" --repo=centos_ppa_repo --distro="${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}" --ksmeta="tree=http://$ipaddr/cobbler/ks_mirror/${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}" --kickstart=/var/lib/cobbler/kickstarts/default.ks
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
echo "failed to add profile ${IMAGE_NAME}-${IMAGE_ARCH}" echo "failed to add profile ${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}"
exit 1 exit 1
else else
echo "profile ${IMAGE_NAME}-${IMAGE_ARCH} is added" echo "profile ${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH} is added"
fi fi
else else
echo "profile $IMAGE_NAME has already existed." echo "profile ${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH} has already existed."
sudo cobbler profile edit --name="${IMAGE_NAME}-${IMAGE_ARCH}" --repo=ppa_repo --distro="${IMAGE_NAME}-${IMAGE_ARCH}" --ksmeta="tree=http://$ipaddr/cobbler/ks_mirror/${IMAGE_NAME}-${IMAGE_ARCH}" --kickstart=/var/lib/cobbler/kickstarts/default.ks sudo cobbler profile edit --name="${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}" --repo=centos_ppa_repo --distro="${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}" --ksmeta="tree=http://$ipaddr/cobbler/ks_mirror/${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}" --kickstart=/var/lib/cobbler/kickstarts/default.ks
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
echo "failed to edit profile ${IMAGE_NAME}-${IMAGE_ARCH}" echo "failed to edit profile ${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}"
exit 1 exit 1
else else
echo "profile ${IMAGE_NAME}-${IMAGE_ARCH} is updated" echo "profile ${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH} is updated"
fi fi
fi fi
ubuntu_found_profile=0
for profile in $(cobbler profile list); do
if [ "$profile" == "${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH}" ]; then
ubuntu_found_profile=1
fi
done
if [ "$ubuntu_found_profile" == "0" ]; then
sudo cobbler profile add --name="${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH}" --repo=ubuntu_ppa_repo --distro="${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH}" --ksmeta="tree=http://$ipaddr/cobbler/ks_mirror/${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH}" --kickstart=/var/lib/cobbler/kickstarts/default.seed
if [[ "$?" != "0" ]]; then
echo "failed to add profile ${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH}"
exit 1
else
echo "profile ${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH} is added"
fi
else
echo "profile ${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH} has already existed."
sudo cobbler profile edit --name="${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH}" --repo=ubuntu_ppa_repo --distro="${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH}" --ksmeta="tree=http://$ipaddr/cobbler/ks_mirror/${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH}" --kickstart=/var/lib/cobbler/kickstarts/default.seed
if [[ "$?" != "0" ]]; then
echo "failed to edit profile ${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH}"
exit 1
else
echo "profile ${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH} is updated"
fi
fi
#clean ubuntu repo
sudo cobbler repo remove --name=${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH}
sudo cobbler reposync
if [[ "$?" != "0" ]]; then
echo "cobbler reposync failed"
exit 1
else
echo "cobbler repos are synced"
fi
echo "Checking cobbler is OK"
sudo cobbler check
if [[ "$?" != "0" ]]; then
echo "cobbler check failed"
exit 1
else
echo "cobbler check passed"
fi
echo "Cobbler configuration complete!" echo "Cobbler configuration complete!"

View File

@ -55,28 +55,30 @@ sudo /opt/compass/bin/addcookbooks.py
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
echo "failed to add cookbooks" echo "failed to add cookbooks"
exit 1 exit 1
else
echo "cookbooks are added to chef server"
fi fi
sudo /opt/compass/bin/adddatabags.py sudo /opt/compass/bin/adddatabags.py
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
echo "failed to add databags" echo "failed to add databags"
exit 1 exit 1
else
echo "databags are added to chef server"
fi fi
sudo /opt/compass/bin/addroles.py sudo /opt/compass/bin/addroles.py
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
echo "failed to add roles" echo "failed to add roles"
exit 1 exit 1
fi else
echo "roles are added to chef server"
# copy the chef validatation keys to cobbler snippets
sudo cp -rf /etc/chef-server/chef-validator.pem /var/lib/cobbler/snippets/chef-validator.pem
if [[ "$?" != "0" ]]; then
echo "failed to copy chef validation keys to cobbler snippets"
exit 1
fi fi
sudo /opt/compass/bin/refresh.sh sudo /opt/compass/bin/refresh.sh
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
echo "failed to refresh compassd service echo "failed to refresh compassd service"
exit 1
else
echo "compassed service is refreshed"
fi fi
sudo service httpd status sudo service httpd status
@ -87,6 +89,13 @@ else
echo "httpd has already started" echo "httpd has already started"
fi fi
mkdir -p /var/log/redis
chown -R redis:root /var/log/redis
mkdir -p /var/lib/redis/
chown -R redis:root /var/lib/redis
mkdir -p /var/run/redis
chown -R redis:root /var/run/redis
sudo service redis status sudo service redis status
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
echo "redis is not started" echo "redis is not started"
@ -102,3 +111,9 @@ if [[ "$?" != "0" ]]; then
else else
echo "compassd has already started" echo "compassd has already started"
fi fi
sudo compass check
if [[ "$?" != "0" ]]; then
echo "compass check failed"
exit 1
fi

View File

@ -5,8 +5,12 @@ sudo yum clean all
sudo yum update -y --skip-broken sudo yum update -y --skip-broken
if [ "$tempest" == "true" ]; then if [ "$tempest" == "true" ]; then
sudo yum install -y virt-install libvirt qemu-kvm libxml2-devel libffi-devel libxslt-devel python-devel sshpass openssl-devel sudo yum install -y virt-install libvirt qemu-kvm libxml2-devel libffi-devel libxslt-devel python-devel sshpass openssl-devel
if [[ "$?" != "0" ]]; then
echo "failed to install tempest yum dependency"
exit 1
fi fi
sudo yum install -y rsyslog logrotate ntp iproute openssh-clients python python-devel git wget python-setuptools syslinux python-netaddr python-flask python-flask-sqlalchemy python-amqplib amqp python-paramiko python-mock mod_wsgi httpd squid dhcp bind rsync yum-utils xinetd tftp-server gcc net-snmp-utils net-snmp net-snmp-python python-daemon unzip openssl openssl098e ca-certificates redis python-redis --skip-broken fi
sudo yum install -y rsyslog logrotate ntp iproute openssh-clients python python-devel git wget python-setuptools syslinux python-netaddr python-flask python-flask-sqlalchemy python-amqplib python-argparse amqp python-paramiko python-mock mod_wsgi httpd squid dhcp bind rsync yum-utils xinetd tftp-server gcc net-snmp-utils net-snmp net-snmp-python python-daemon unzip openssl openssl098e ca-certificates redis python-redis --skip-broken
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
echo "failed to install yum dependency" echo "failed to install yum dependency"
exit 1 exit 1
@ -16,21 +20,37 @@ fi
sudo service ntpd stop sudo service ntpd stop
ntpdate 0.centos.pool.ntp.org ntpdate 0.centos.pool.ntp.org
sudo service ntpd start sudo service ntpd start
sudo service ntpd status
if [[ "$?" != "0" ]]; then
echo "ntpd is not started"
exit 1
fi
sudo easy_install --upgrade pip==1.5.1 sudo easy_install --upgrade pip
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
echo "failed to install easy install" echo "failed to install easy install"
exit 1 exit 1
fi fi
# pip install flask-sqlalchemy need to remove /usr/lib64/python2.6/site-packages/easy-install.pth
cp -n /usr/lib/python2.6/site-packages/easy-install* /usr/lib64/python2.6/site-packages/
if [ "$tempest" == "true" ]; then if [ "$tempest" == "true" ]; then
sudo pip install -U setuptools sudo pip install -U setuptools
sudo pip install -U setuptools
fi
sudo pip install -r $COMPASSDIR/requirements.txt
sudo pip install -r $COMPASSDIR/test-requirements.txt
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
echo "failed to install pip packages" echo "failed to install setuptools"
exit 1
fi
fi
sudo pip install -U -r $COMPASSDIR/requirements.txt
if [[ "$?" != "0" ]]; then
echo "failed to install compass requirement packages"
exit 1
fi
sudo pip install -U -r $COMPASSDIR/test-requirements.txt
if [[ "$?" != "0" ]]; then
echo "failed to install compass test require packages"
exit 1 exit 1
fi fi

View File

@ -30,30 +30,49 @@ export CBLR_USER=${CBLR_USER:-}
export CBLR_PASSWD=${CBLR_PASSWD:-} export CBLR_PASSWD=${CBLR_PASSWD:-}
export IMAGE_TYPE=${IMAGE_TYPE:-"CentOS"} export IMAGE_TYPE=${IMAGE_TYPE:-"CentOS"}
export IMAGE_TYPE_OTHER=${IMAGE_TYPE_OTHER:-"el"}
export IMAGE_VERSION_MAJOR=${IMAGE_VERSION_MAJOR:-"6"} export IMAGE_VERSION_MAJOR=${IMAGE_VERSION_MAJOR:-"6"}
export IMAGE_VERSION_MINOR=${IMAGE_VERSION_MINOR:-"5"} export IMAGE_VERSION_NINOR=${IMAGE_VERSION_MINOR:-"5"}
export IMAGE_VERSION=${IMAGE_VERSION:-"${IMAGE_VERSION_MAJOR}.${IMAGE_VERSION_MINOR}"} export IMAGE_VERSION=${IMAGE_VERSION:-"${IMAGE_VERSION_MAJOR}.${IMAGE_VERSION_MINOR}"}
export IMAGE_NAME=${IMAGE_NAME:-"${IMAGE_TYPE}-${IMAGE_VERSION}"} export IMAGE_NAME=${IMAGE_NAME:-"${IMAGE_TYPE}-${IMAGE_VERSION}"}
export IMAGE_ARCH=${IMAGE_ARCH:-"x86_64"} export IMAGE_ARCH=${IMAGE_ARCH:-"x86_64"}
export IMAGE_SOURCE=${IMAGE_SOURCE:-"http://mirror.rackspace.com/${IMAGE_TYPE}/${IMAGE_VERSION_MAJOR}/isos/${IMAGE_ARCH}/${IMAGE_TYPE}-${IMAGE_VERSION}-${IMAGE_ARCH}-minimal.iso"}
export CENTOS_IMAGE_TYPE=${CENTOS_IMAGE_TYPE:-"CentOS"}
export CENTOS_IMAGE_TYPE_OTHER=${CENTOS_IMAGE_TYPE_OTHER:-"el"}
export CENTOS_IMAGE_VERSION_MAJOR=${CENTOS_IMAGE_VERSION_MAJOR:-"6"}
export CENTOS_IMAGE_VERSION_MINOR=${CENTOS_IMAGE_VERSION_MINOR:-"5"}
export CENTOS_IMAGE_VERSION=${CENTOS_IMAGE_VERSION:-"${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_VERSION_MINOR}"}
export CENTOS_IMAGE_NAME=${CENTOS_IMAGE_NAME:-"${CENTOS_IMAGE_TYPE}-${CENTOS_IMAGE_VERSION}"}
export CENTOS_IMAGE_ARCH=${CENTOS_IMAGE_ARCH:-"x86_64"}
export CENTOS_IMAGE_SOURCE=${CENTOS_IMAGE_SOURCE:-"http://mirror.rackspace.com/${CENTOS_IMAGE_TYPE,,}/${CENTOS_IMAGE_VERSION_MAJOR}/isos/${CENTOS_IMAGE_ARCH}/${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}-minimal.iso"}
export UBUNTU_IMAGE_TYPE=${UBUNTU_IMAGE_TYPE:-"Ubuntu"}
export UBUNTU_IMAGE_VERSION_MAJOR=${UBUNTU_IMAGE_VERSION_MAJOR:-"13"}
export UBUNTU_IMAGE_VERSION_MINOR=${UBUNTU_IMAGE_VERSION_MINOR:-"04"}
export UBUNTU_IMAGE_VERSION=${UBUNTU_IMAGE_VERSION:-"${UBUNTU_IMAGE_VERSION_MAJOR}.${UBUNTU_IMAGE_VERSION_MINOR}"}
export UBUNTU_IMAGE_NAME=${UBUNTU_IMAGE_NAME:-"${UBUNTU_IMAGE_TYPE}-${UBUNTU_IMAGE_VERSION}"}
export UBUNTU_IMAGE_ARCH=${UBUNTU_IMAGE_ARCH:-"x86_64"}
export UBUNTU_IMAGE_ARCH_OTHER=${UBUNTU_IMAGE_ARCH_OTHER:-"amd64"}
export UBUNTU_IMAGE_SOURCE=${UBUNTU_IMAGE_SOURCE:-"http://releases.ubuntu.com/${UBUNTU_IMAGE_VERSION}/${UBUNTU_IMAGE_TYPE,,}-${UBUNTU_IMAGE_VERSION}-server-${UBUNTU_IMAGE_ARCH_OTHER}.iso"}
export COBBLER_PASSWORD=${COBBLER_PASSWORD:-"cobbler"} export COBBLER_PASSWORD=${COBBLER_PASSWORD:-"cobbler"}
# Currently the use of Javascript MVC is set to version 3.2.4 # Currently the use of Javascript MVC is set to version 3.2.4
export JS_MVC=${JS_MVC:-"javascriptmvc-3.2.4"} export JS_MVC=${JS_MVC:-"javascriptmvc-3.2.4"}
# set the chef packages download path # set the chef packages download path
export CHEF_SRV=${CHEF_SRV:-"http://opscode-omnibus-packages.s3.amazonaws.com/el/${IMAGE_VERSION_MAJOR}/${IMAGE_ARCH}/chef-server-11.0.8-1.el6.${IMAGE_ARCH}.rpm"} export CHEF_SRV=${CHEF_SRV:-"http://opscode-omnibus-packages.s3.amazonaws.com/${IMAGE_TYPE_OTHER}/${IMAGE_VERSION_MAJOR}/${IMAGE_ARCH}/chef-server-11.0.8-1.${IMAGE_TYPE_OTHER}${IMAGE_VERSION_MAJOR}.${IMAGE_ARCH}.rpm"}
export CHEF_CLIENT=${CHEF_CLIENT:="http://opscode-omnibus-packages.s3.amazonaws.com/el/${IMAGE_VERSION_MAJOR}/${IMAGE_ARCH}/chef-11.8.0-1.el6.${IMAGE_ARCH}.rpm"} export CHEF_CLIENT=${CHEF_CLIENT:-"http://opscode-omnibus-packages.s3.amazonaws.com/${IMAGE_TYPE_OTHER}/${IMAGE_VERSION_MAJOR}/${IMAGE_ARCH}/chef-11.8.0-1.${IMAGE_TYPE_OTHER}${IMAGE_VERSION_MAJOR}.${IMAGE_ARCH}.rpm"}
export CENTOS_CHEF_CLIENT=${CENTOS_CHEF_CLIENT:-"http://opscode-omnibus-packages.s3.amazonaws.com/${CENTOS_IMAGE_TYPE_OTHER}/${CENTOS_IMAGE_VERSION_MAJOR}/${CENTOS_IMAGE_ARCH}/chef-11.8.0-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm"}
export UBUNTU_CHEF_CLIENT=${UBUNTU_CHEF_CLIENT:-"http://opscode-omnibus-packages.s3.amazonaws.com/${UBUNTU_IMAGE_TYPE,,}/${UBUNTU_IMAGE_VERSION}/${UBUNTU_IMAGE_ARCH}/chef_11.8.0-1.${UBUNTU_IMAGE_TYPE,,}.${UBUNTU_IMAGE_VERSION}_${UBUNTU_IMAGE_ARCH_OTHER}.deb"}
# Set Chef password for Chef web UI # Set Chef password for Chef web UI
export CHEF_PASSWD=${CHEF_PASSWD:-"root1234"} export CHEF_PASSWD=${CHEF_PASSWD:-"root1234"}
# Set Compass-web and Compass-adpater variables # Set Compass-web and Compass-adpater variables
export WEB_HOME=${WEB_HOME:='/tmp/web'} export WEB_HOME=${WEB_HOME:-'/tmp/web'}
export ADAPTERS_HOME=${ADAPTERS_HOME:-'/tmp/adapter'} export ADAPTERS_HOME=${ADAPTERS_HOME:-'/tmp/adapter'}
export WEB_SOURCE=${WEB_SOURCE:-} export WEB_SOURCE=${WEB_SOURCE:-}
export ADAPTERS_SOURCE=${ADAPTERS_SOURCE:-} export ADAPTERS_SOURCE=${ADAPTERS_SOURCE:-}
export WEB_GERRIT_URL=${WEB_GERRIT_URL:-}
export ADAPTERS_GERRIT_URL=${ADAPTERS_GERRIT_URL:-}
# Set compass environment # Set compass environment
export SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) export SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

View File

@ -30,28 +30,47 @@ export NAMESERVER_DOMAINS=ods.com
# the repo url # the repo url
export WEB_SOURCE='http://git.openstack.org/stackforge'/compass-web export WEB_SOURCE='http://git.openstack.org/stackforge'/compass-web
export ADAPTERS_SOURCE='http://git.openstack.org/stackforge/compass-adapters' export ADAPTERS_SOURCE='http://git.openstack.org/stackforge/compass-adapters'
export WEB_GERRIT_URL='https://review.openstack.org/stackforge/compass-web'
export ADAPTERS_GERRIT_URL='https://review.openstack.org/stackforge/compass-adapters'
# set the default cobbler user "cobbler" password, if not set, the default will be cobbler/cobbler # set the default cobbler user "cobbler" password, if not set, the default will be cobbler/cobbler
export CBLR_USER=cobbler export CBLR_USER=cobbler
export CBLR_PASSWD=cobbler export CBLR_PASSWD=cobbler
# IMAGE_SOURCE is where you host your CentOS image # IMAGE_SOURCE is where you host your CentOS image
#export IMAGE_SOURCE=http://12.234.32.58/software/OS/centos/centos6.4/CentOS-6.4-x86_64-minimal.iso
export IMAGE_TYPE=${IMAGE_TYPE:-"CentOS"} export IMAGE_TYPE=${IMAGE_TYPE:-"CentOS"}
export IMAGE_TYPE_OTHER=${IMAGE_TYPE_OTHER:-"el"}
export IMAGE_VERSION_MAJOR=${IMAGE_VERSION_MAJOR:-"6"} export IMAGE_VERSION_MAJOR=${IMAGE_VERSION_MAJOR:-"6"}
export IMAGE_VERSION_MINOR=${IMAGE_VERSION_MINOR:-"5"} export IMAGE_VERSION_MINOR=${IMAGE_VERSION_MINOR:-"5"}
export IMAGE_VERSION=${IMAGE_VERSION:-"${IMAGE_VERSION_MAJOR}.${IMAGE_VERSION_MINOR}"} export IMAGE_VERSION=${IMAGE_VERSION:-"${IMAGE_VERSION_MAJOR}.${IMAGE_VERSION_MINOR}"}
export IMAGE_NAME=${IMAGE_NAME:-"${IMAGE_TYPE}-${IMAGE_VERSION}"} export IMAGE_NAME=${IMAGE_NAME:-"${IMAGE_TYPE}-${IMAGE_VERSION}"}
export IMAGE_ARCH=${IMAGE_ARCH:-"x86_64"} export IMAGE_ARCH=${IMAGE_ARCH:-"x86_64"}
export IMAGE_SOURCE=${IMAGE_SOURCE:-"http://mirror.rackspace.com/${IMAGE_TYPE}/${IMAGE_VERSION_MAJOR}/isos/${IMAGE_ARCH}/${IMAGE_TYPE}-${IMAGE_VERSION}-${IMAGE_ARCH}-minimal.iso"}
export CENTOS_IMAGE_TYPE=${CENTOS_IMAGE_TYPE:-"CentOS"}
export CENTOS_IMAGE_TYPE_OTHER=${CENTOS_IMAGE_TYPE_OTHER:-"el"}
export CENTOS_IMAGE_VERSION_MAJOR=${CENTOS_IMAGE_VERSION_MAJOR:-"6"}
export CENTOS_IMAGE_VERSION_MINOR=${CENTOS_IMAGE_VERSION_MINOR:-"5"}
export CENTOS_IMAGE_VERSION=${CENTOS_IMAGE_VERSION:-"${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_VERSION_MINOR}"}
export CENTOS_IMAGE_NAME=${CENTOS_IMAGE_NAME:-"${CENTOS_IMAGE_TYPE}-${CENTOS_IMAGE_VERSION}"}
export CENTOS_IMAGE_ARCH=${CENTOS_IMAGE_ARCH:-"x86_64"}
export CENTOS_IMAGE_SOURCE=${CENTOS_IMAGE_SOURCE:-"http://mirror.rackspace.com/${CENTOS_IMAGE_TYPE,,}/${CENTOS_IMAGE_VERSION_MAJOR}/isos/${CENTOS_IMAGE_ARCH}/${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}-minimal.iso"}
export UBUNTU_IMAGE_TYPE=${UBUNTU_IMAGE_TYPE:-"Ubuntu"}
export UBUNTU_IMAGE_VERSION_MAJOR=${UBUNTU_IMAGE_VERSION_MAJOR:-"13"}
export UBUNTU_IMAGE_VERSION_MINOR=${UBUNTU_IMAGE_VERSION_MINOR:-"04"}
export UBUNTU_IMAGE_VERSION=${UBUNTU_IMAGE_VERSION:-"${UBUNTU_IMAGE_VERSION_MAJOR}.${UBUNTU_IMAGE_VERSION_MINOR}"}
export UBUNTU_IMAGE_NAME=${UBUNTU_IMAGE_NAME:-"${UBUNTU_IMAGE_TYPE}-${UBUNTU_IMAGE_VERSION}"}
export UBUNTU_IMAGE_ARCH=${UBUNTU_IMAGE_ARCH:-"x86_64"}
export UBUNTU_IMAGE_ARCH_OTHER=${UBUNTU_IMAGE_ARCH_OTHER:-"amd64"}
export UBUNTU_IMAGE_SOURCE=${UBUNTU_IMAGE_SOURCE:-"http://releases.ubuntu.com/${UBUNTU_IMAGE_VERSION}/${UBUNTU_IMAGE_TYPE,,}-${UBUNTU_IMAGE_VERSION}-server-${UBUNTU_IMAGE_ARCH_OTHER}.iso"}
export COBBLER_PASSWORD=${COBBLER_PASSWORD:-"cobbler"} export COBBLER_PASSWORD=${COBBLER_PASSWORD:-"cobbler"}
# Currently the use of Javascript MVC is set to version 3.2.4 # Currently the use of Javascript MVC is set to version 3.2.4
export JS_MVC=javascriptmvc-3.2.4 export JS_MVC=javascriptmvc-3.2.4
# set the chef packages download path # set the chef packages download path
export CHEF_SRV=http://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chef-server-11.0.8-1.el6.x86_64.rpm export CHEF_SRV=${CHEF_SRV:-"http://opscode-omnibus-packages.s3.amazonaws.com/${IMAGE_TYPE_OTHER}/${IMAGE_VERSION_MAJOR}/${IMAGE_ARCH}/chef-server-11.0.8-1.${IMAGE_TYPE_OTHER}${IMAGE_VERSION_MAJOR}.${IMAGE_ARCH}.rpm"}
export CHEF_CLIENT=${CHEF_CLIENT:-"http://opscode-omnibus-packages.s3.amazonaws.com/${IMAGE_TYPE_OTHER}/${IMAGE_VERSION_MAJOR}/${IMAGE_ARCH}/chef-11.8.0-1.${IMAGE_TYPE_OTHER}${IMAGE_VERSION_MAJOR}.${IMAGE_ARCH}.rpm"}
export CENTOS_CHEF_CLIENT=${CENTOS_CHEF_CLIENT:-"http://opscode-omnibus-packages.s3.amazonaws.com/${CENTOS_IMAGE_TYPE_OTHER}/${CENTOS_IMAGE_VERSION_MAJOR}/${CENTOS_IMAGE_ARCH}/chef-11.8.0-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm"}
export UBUNTU_CHEF_CLIENT=${UBUNTU_CHEF_CLIENT:-"http://opscode-omnibus-packages.s3.amazonaws.com/${UBUNTU_IMAGE_TYPE,,}/${UBUNTU_IMAGE_VERSION}/${UBUNTU_IMAGE_ARCH}/chef_11.8.0-1.${UBUNTU_IMAGE_TYPE,,}.${UBUNTU_IMAGE_VERSION}_${UBUNTU_IMAGE_ARCH_OTHER}.deb"}
# Set Chef password for Chef web UI # Set Chef password for Chef web UI
export CHEF_PASSWD=root1234 export CHEF_PASSWD=root1234

View File

@ -24,21 +24,43 @@ exlock_now || exit 1
### BEGIN OF SCRIPT ### ### BEGIN OF SCRIPT ###
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source $DIR/install.conf
### Change selinux security policy ### Change selinux security policy
echo 0 > /selinux/enforce echo 0 > /selinux/enforce
### Add epel repo ### Add epel repo
sudo rpm -q epel-release-6-8 sudo rpm -q epel-release
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
sudo rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm >& /dev/null sudo rpm -Uvh http://download.fedoraproject.org/pub/epel/${IMAGE_VERSION_MAJOR}/${IMAGE_ARCH}/epel-release-6-8.noarch.rpm >& /dev/null
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo "failed to install epel" echo "failed to install epel-release"
exit 1 exit 1
else
echo "sucessfaully installed epel-release"
fi fi
else
echo "epel-release is already installed"
fi fi
sed -i 's/^mirrorlist=https/mirrorlist=http/g' /etc/yum.repos.d/epel.repo sed -i 's/^mirrorlist=https/mirrorlist=http/g' /etc/yum.repos.d/epel.repo
### Add atomic repo
sudo rpm -q atomic-release
if [ "$?" != "0" ]; then
sudo rpm -Uvh http://www6.atomicorp.com/channels/atomic/${IMAGE_TYPE,,}/${IMAGE_VERSION_MAJOR}/${IMAGE_ARCH}/RPMS/atomic-release-1.0-19.${IMAGE_TYPE_OTHER}${IMAGE_VERSION_MAJOR}.art.noarch.rpm >& /dev/null
if [ "$?" != "0" ]; then
echo "failed to install atomic-release"
exit 1
else
echo "successfully installed atomic-release"
fi
else
echo "atomic-release is already installed"
fi
sed -i 's/^mirrorlist=https/mirrorlist=http/g' /etc/yum.repos.d/atomic.repo
### Trap any error code with related filename and line. ### Trap any error code with related filename and line.
errtrap() errtrap()
{ {
@ -52,6 +74,12 @@ fi
# Install figlet # Install figlet
sudo yum -y install figlet >& /dev/null sudo yum -y install figlet >& /dev/null
if [[ "$?" != "0" ]]; then
echo "failed to install figlet"
exit 1
else
echo "figlet is installed"
fi
figlet -ctf slant Compass Installer figlet -ctf slant Compass Installer
while [ $1 ]; do while [ $1 ]; do
@ -72,7 +100,6 @@ ipaddr_convert()
} }
# Load variables # Load variables
source $DIR/install.conf
loadvars() loadvars()
{ {
varname=${1,,} varname=${1,,}
@ -138,6 +165,8 @@ ipcalc $IP_START -c
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "ip start $IP_START format should be x.x.x.x" echo "ip start $IP_START format should be x.x.x.x"
exit 1 exit 1
else
echo "ip start address is $IP_START"
fi fi
ip_start_net=$(ipcalc $IP_START $netmask -n |cut -f 2 -d '=') ip_start_net=$(ipcalc $IP_START $netmask -n |cut -f 2 -d '=')
if [[ "$ip_start_net" != "$netaddr" ]]; then if [[ "$ip_start_net" != "$netaddr" ]]; then
@ -171,31 +200,25 @@ if [ $? -ne 0 ]; then
fi fi
loadvars NAMESERVER_DOMAINS "ods.com" loadvars NAMESERVER_DOMAINS "ods.com"
loadvars WEB_SOURCE 'http://git.openstack.org/stackforge/compass-web' loadvars WEB_SOURCE 'http://git.openstack.org/stackforge/compass-web'
if [[ "$WEB_SOURCE" =~ https?:// ]]; then
loadvars WEB_GERRIT_URL 'https://review.openstack.org/stackforge/compass-web'
fi
loadvars ADAPTERS_SOURCE 'http://git.openstack.org/stackforge/compass-adapters' loadvars ADAPTERS_SOURCE 'http://git.openstack.org/stackforge/compass-adapters'
if [[ "$ADAPTERS_SOURCE" =~ https?:// ]]; then
loadvars ADAPTERS_GERRIT_URL 'https://review.openstack.org/stackforge/compass-adapters'
fi
echo "script dir: $SCRIPT_DIR" echo "script dir: $SCRIPT_DIR"
echo "compass dir is $COMPASSDIR" echo "compass dir is $COMPASSDIR"
echo "Install the Dependencies" echo "Install the Dependencies"
source ${COMPASSDIR}/install/dependency.sh source ${COMPASSDIR}/install/dependency.sh || exit $?
echo "Prepare the Installation" echo "Prepare the Installation"
source ${COMPASSDIR}/install/prepare.sh source ${COMPASSDIR}/install/prepare.sh || exit $?
echo "Install the OS Installer Tool" echo "Install the OS Installer Tool"
source ${COMPASSDIR}/install/$OS_INSTALLER.sh source ${COMPASSDIR}/install/$OS_INSTALLER.sh || exit $?
echo "Install the Package Installer Tool" echo "Install the Package Installer Tool"
source ${COMPASSDIR}/install/$PACKAGE_INSTALLER.sh source ${COMPASSDIR}/install/$PACKAGE_INSTALLER.sh || exit $?
echo "Download and Setup Compass and related services" echo "Download and Setup Compass and related services"
source ${COMPASSDIR}/install/compass.sh source ${COMPASSDIR}/install/compass.sh || exit $?
figlet -ctf slant Installation Complete! figlet -ctf slant Installation Complete!
echo -e "It takes\x1b[32m $SECONDS \x1b[0mseconds during the installation." echo -e "It takes\x1b[32m $SECONDS \x1b[0mseconds during the installation."

View File

@ -13,6 +13,8 @@ copy2dir()
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$destdir is not git repo" echo "$destdir is not git repo"
rm -rf $destdir rm -rf $destdir
else
echo "$destdir is git repo"
fi fi
cd - cd -
fi fi
@ -33,6 +35,8 @@ copy2dir()
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "failed to git clone $repo $destdir" echo "failed to git clone $repo $destdir"
exit 1 exit 1
else
echo "git clone $repo $destdir suceeded"
fi fi
cd $destdir cd $destdir
git reset --hard remotes/origin/$git_branch git reset --hard remotes/origin/$git_branch
@ -60,11 +64,15 @@ copy2dir()
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "failed to copy $repo to $destdir" echo "failed to copy $repo to $destdir"
exit 1 exit 1
else
echo "copy $repo to $destdir succeeded"
fi fi
fi fi
if [[ ! -d $destdir && ! -L $destdir ]]; then if [[ ! -d $destdir && ! -L $destdir ]]; then
echo "$destdir doest not exist" echo "$destdir does not exist"
exit 1 exit 1
else
echo "$destdir is ready"
fi fi
cd $SCRIPT_DIR cd $SCRIPT_DIR
} }
@ -139,6 +147,7 @@ if [ -z $WEB_SOURCE ]; then
exit 1 exit 1
fi fi
copy2dir "$WEB_SOURCE" "$WEB_HOME" "stackforge/compass-web" copy2dir "$WEB_SOURCE" "$WEB_HOME" "stackforge/compass-web"
if [ -z $ADAPTERS_SOURCE ]; then if [ -z $ADAPTERS_SOURCE ]; then
echo "adpaters source $ADAPTERS_SOURCE is not set" echo "adpaters source $ADAPTERS_SOURCE is not set"
exit 1 exit 1
@ -148,6 +157,10 @@ copy2dir "$ADAPTERS_SOURCE" "$ADAPTERS_HOME" "stackforge/compass-adapters"
if [ "$tempest" == "true" ]; then if [ "$tempest" == "true" ]; then
if [[ ! -e /tmp/tempest ]]; then if [[ ! -e /tmp/tempest ]]; then
git clone http://git.openstack.org/openstack/tempest /tmp/tempest git clone http://git.openstack.org/openstack/tempest /tmp/tempest
if [[ "$?" != "0" ]]; then
echo "failed to git clone tempest project"
exit 1
fi
cd /tmp/tempest cd /tmp/tempest
git checkout grizzly-eol git checkout grizzly-eol
else else
@ -171,6 +184,7 @@ download()
echo "$package already exists" echo "$package already exists"
else else
if [[ "$url" =~ (http|https|ftp):// ]]; then if [[ "$url" =~ (http|https|ftp):// ]]; then
echo "downloading $url to /tmp/${package}"
wget -c --progress=bar:force -O /tmp/${package}.tmp $url wget -c --progress=bar:force -O /tmp/${package}.tmp $url
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
echo "failed to download $package" echo "failed to download $package"
@ -188,6 +202,7 @@ download()
fi fi
fi fi
if [[ "$action" == "install" ]]; then if [[ "$action" == "install" ]]; then
echo "install /tmp/$package"
sudo rpm -Uvh /tmp/$package sudo rpm -Uvh /tmp/$package
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
echo "failed to install $package" echo "failed to install $package"
@ -196,45 +211,58 @@ download()
echo "$package is installed" echo "$package is installed"
fi fi
elif [[ "$action" == "copy" ]]; then elif [[ "$action" == "copy" ]]; then
echo "copy /tmp/$package to $destdir"
destdir=$4 destdir=$4
sudo cp /tmp/$package $destdir sudo cp /tmp/$package $destdir
elif [[ "$action" == "unzip" ]]; then elif [[ "$action" == "unzip" ]]; then
unzipped_package=${package%%.zip} unzipped_package=${package%%.zip}
destdir=$4
echo "unzip /tmp/$package to /tmp/$unzipped_package and copy to $destdir"
sudo rm -rf /tmp/$unzipped_package sudo rm -rf /tmp/$unzipped_package
sudo unzip -o /tmp/$package /tmp/ pushd `pwd`
cd /tmp
sudo unzip -o /tmp/$package
popd
sudo cp -rf /tmp/$unzipped_package/. $destdir sudo cp -rf /tmp/$unzipped_package/. $destdir
fi fi
} }
# download js mvc # download js mvc
download http://github.com/downloads/bitovi/javascriptmvc/$JS_MVC.zip $JS_MVC.zip unzip $WEB_HOME/public/ download http://github.com/downloads/bitovi/javascriptmvc/$JS_MVC.zip $JS_MVC.zip unzip $WEB_HOME/public/ || exit $?
# download cobbler related packages # download cobbler related packages
ppa_repo_packages="ntp-4.2.6p5-1.el6.${IMAGE_TYPE,,}.$IMAGE_ARCH.rpm centos_ppa_repo_packages="
openssh-clients-5.3p1-94.el6.${IMAGE_ARCH}.rpm ntp-4.2.6p5-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_TYPE,,}.${CENTOS_IMAGE_ARCH}.rpm
iproute-2.6.32-31.el6.${IMAGE_ARCH}.rpm openssh-clients-5.3p1-94.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
wget-1.12-1.8.el6.${IMAGE_ARCH}.rpm iproute-2.6.32-31.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
ntpdate-4.2.6p5-1.el6.${IMAGE_TYPE,,}.${IMAGE_ARCH}.rpm" wget-1.12-1.8.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
for f in $ppa_repo_packages ntpdate-4.2.6p5-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_TYPE,,}.${CENTOS_IMAGE_ARCH}.rpm"
do
download ftp://rpmfind.net/linux/${IMAGE_TYPE,,}/${IMAGE_VERSION_MAJOR}/os/${IMAGE_ARCH}/Packages/$f $f for f in $centos_ppa_repo_packages; do
download ftp://rpmfind.net/linux/${IMAGE_TYPE,,}/${IMAGE_VERSION_MAJOR}/os/${IMAGE_ARCH}/Packages/$f $f || exit $?
done done
ppa_repo_rsyslog_packages="json-c-0.10-2.el6.$IMAGE_ARCH.rpm centos_ppa_repo_rsyslog_packages="
libestr-0.1.9-1.el6.$IMAGE_ARCH.rpm json-c-0.10-2.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
libgt-0.3.11-1.el6.$IMAGE_ARCH.rpm libestr-0.1.9-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
liblogging-1.0.4-1.el6.$IMAGE_ARCH.rpm libgt-0.3.11-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
rsyslog-7.6.3-1.el6.$IMAGE_ARCH.rpm" liblogging-1.0.4-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
for f in $ppa_repo_rsyslog_packages rsyslog-7.6.3-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm"
do
download http://rpms.adiscon.com/v7-stable/epel-6/${IMAGE_ARCH}/RPMS/$f $f for f in $centos_ppa_repo_rsyslog_packages; do
download http://rpms.adiscon.com/v7-stable/epel-6/${IMAGE_ARCH}/RPMS/$f $f || exit $?
done done
download "$IMAGE_SOURCE" ${IMAGE_NAME}-${IMAGE_ARCH}.iso download $CHEF_CLIENT `basename $CHEF_CLIENT` || exit $?
download $CHEF_CLIENT chef-client download $CENTOS_CHEF_CLIENT `basename $CENTOS_CHEF_CLIENT` || exit $?
download $UBUNTU_CHEF_CLIENT `basename $UBUNTU_CHEF_CLIENT` || exit $?
# download chef related packages # download chef related packages
download $CHEF_SRV chef-server download $CHEF_SRV chef-server || exit $?
# download os images
download "$CENTOS_IMAGE_SOURCE" ${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}.iso || exit $?
download "$UBUNTU_IMAGE_SOURCE" ${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH}.iso || exit $?
# Install net-snmp # Install net-snmp
sudo cp -rn /etc/snmp/snmp.conf /root/backup/ sudo cp -rn /etc/snmp/snmp.conf /root/backup/

View File

@ -54,14 +54,12 @@ cache_dir aufs /var/squid/cache 25000 16 256
cache_store_log /var/log/squid/store.log cache_store_log /var/log/squid/store.log
access_log none access_log none
vary_ignore_expire on
# Leave coredumps in the first cache dir # Leave coredumps in the first cache dir
coredump_dir /var/spool/squid coredump_dir /var/spool/squid
reload_into_ims on
# Add any of your own refresh_pattern entries above these. # Add any of your own refresh_pattern entries above these.
refresh_pattern . 86400 50% 518400 ignore-reload ignore-no-store ignore-must-revalidate ignore-private ignore-auth override-expire override-lastmod refresh_pattern . 86400 50% 518400
quick_abort_min -1 QB quick_abort_min -1 QB
read_ahead_gap 100 MB read_ahead_gap 100 MB
@ -70,5 +68,4 @@ positive_dns_ttl 30 second
negative_dns_ttl 1 second negative_dns_ttl 1 second
pipeline_prefetch on pipeline_prefetch on
vary_ignore_expire on
request_timeout 15 minute request_timeout 15 minute