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 = {
'match_kickstart': (
'/var/lib/cobbler/kickstarts/',
['default.ks', ]
['default.ks', 'default.seed']
),
'match_snippets': (
'/var/lib/cobbler/snippets/',
[
'chef',
'chef-validator.pem',
'client.rb',
'kickstart_done',
'kickstart_start',
'network_config',
'ntp.conf',
'partition_disks',
'partition_select',
'post_anamon',
'post_install_network_config',
'pre_anamon',
'pre_install_network_config',
'rsyslogchef',
'rsyslogconf',
'yum.conf',
'kickstart_pre_partition_disks',
'kickstart_partition_disks',
'kickstart_pre_anamon',
'kickstart_post_anamon',
'kickstart_pre_install_network_config',
'kickstart_network_config',
'kickstart_post_install_network_config',
'kickstart_chef',
'kickstart_ntp',
'kickstart_yum_repo_config',
'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': (
@ -114,7 +120,7 @@ class OsInstallerCheck(base.BaseCheck):
),
'match_repo_mirror': (
'/var/www/cobbler/',
['repo_mirror/ppa_repo']
['repo_mirror']
),
'match_iso': (
'/var/lib/cobbler/',

View File

@ -19,7 +19,6 @@
import fnmatch
import functools
import logging
import traceback
from compass.config_management.installers import package_installer
from compass.config_management.utils.config_translator import ConfigTranslator
@ -220,11 +219,10 @@ class Installer(package_installer.Installer):
client.delete()
logging.debug(
'delete %s for host %s ', target_system, node_name)
except Exception:
except Exception as error:
logging.debug(
'failed to delete %s for host %s: %s',
target_system, node_name,
''.join(traceback.format_stack()))
target_system, node_name, error)
else:
node.run_list = []
@ -355,11 +353,10 @@ class Installer(package_installer.Installer):
logging.debug(
'databag item %s is removed from target_system %s',
bag_item_name, target_system)
except Exception:
except Exception as error:
logging.debug(
'no databag item %s to delete from target_system %s: %s',
bag_item_name, target_system,
''.join(traceback.format_stack()))
bag_item_name, target_system, error)
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.
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(
file_matchers=[
FileMatcher(
@ -257,7 +399,21 @@ ADAPTER_CONFIGURATIONS = [
item_matcher=PACKAGE_INSTALLER_CONFIGURATIONS['openstack'],
min_progress=0.6,
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,
package_installer, target_system):
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 '
'package_installer %s, target_system %s',

View File

@ -16,6 +16,8 @@
.. moduleauthor:: Xiaodong Wang <xiaodongwang@huawei.com>
"""
import logging
from celery.signals import setup_logging
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).
:type oper: str
"""
poll_switch.poll_switch(ip_addr, req_obj=req_obj, oper=oper)
try:
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')
@ -61,7 +66,10 @@ def deploy_clusters(cluster_hosts):
:param cluster_hosts: the cluster and hosts of each cluster to deploy.
:type cluster_hosts: dict of int to list of int
"""
deploy.deploy(cluster_hosts)
try:
deploy.deploy(cluster_hosts)
except Exception as error:
logging.exception(error)
@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.
:type cluster_hosts: dict of int to list of int
"""
reinstall.reinstall(cluster_hosts)
try:
reinstall.reinstall(cluster_hosts)
except Exception as error:
logging.exception(error)
@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.
:type cluster_hosts: dict of int to list of int
"""
clean_deployment.clean_deployment(cluster_hosts)
try:
clean_deployment.clean_deployment(cluster_hosts)
except Exception as error:
logging.exception(error)
@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.
:type cluster_hosts: dict of int to list of int
"""
clean_installing_progress.clean_installing_progress(cluster_hosts)
try:
clean_installing_progress.clean_installing_progress(cluster_hosts)
except Exception as error:
logging.exception(error)
@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.
:type cluster_hosts: dict of int to list of int
"""
update_progress.update_progress(cluster_hosts)
try:
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//"
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
if [[ "$?" != "0" ]]; then
download $CHEF_SRV chef-server install
download $CHEF_SRV chef-server install || exit $?
else
echo "chef-server has already installed"
fi
@ -47,7 +47,7 @@ fi
# configure chef client and knife
rpm -q chef
if [[ "$?" != "0" ]]; then
download $CHEF_CLIENT chef-client install
download $CHEF_CLIENT `basename $CHEF_CLIENT` install || exit $?
else
echo "chef has already installed"
fi

View File

@ -2,7 +2,7 @@
#
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
echo "failed to install cobbler related packages"
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 rm -rf /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 chmod 777 /var/lib/cobbler/snippets
sudo chmod -R 666 /var/lib/cobbler/snippets/*
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.seed
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.seed
sudo mkdir /var/www/cblr_ks
sudo chmod 755 /var/www/cblr_ks
sudo cp -rf $ADAPTERS_HOME/cobbler/conf/cobbler.conf /etc/httpd/conf.d/
@ -120,6 +121,8 @@ sudo service iptables status
if [[ "$?" == "0" ]]; then
echo "iptables is running"
exit 1
else
echo "iptables is already stopped"
fi
echo "disable selinux temporarily"
@ -130,176 +133,322 @@ sudo service cobblerd restart
sudo cobbler get-loaders
sudo cobbler sync
sudo service xinetd restart
sudo cobbler check
echo "Checking if httpd is running"
sudo service httpd status
if [[ "$?" == "0" ]]; then
echo "httpd is running."
echo "httpd is running."
else
echo "httpd is not running"
exit 1
echo "httpd is not running"
exit 1
fi
echo "Checking if dhcpd is running"
sudo service dhcpd status
if [[ "$?" == "0" ]]; then
echo "dhcpd is running."
echo "dhcpd is running."
else
echo "dhcpd is not running"
exit 1
echo "dhcpd is not running"
exit 1
fi
echo "Checking if named is running"
sudo service named status
if [[ "$?" == "0" ]]; then
echo "named is running."
echo "named is running."
else
echo "named is not running"
exit 1
echo "named is not running"
exit 1
fi
echo "Checking if xinetd is running"
sudo service xinetd status
if [[ "$?" == "0" ]]; then
echo "xinetd is running."
echo "xinetd is running."
else
echo "xinetd is not running"
exit 1
echo "xinetd is not running"
exit 1
fi
echo "Checking if cobblerd is running"
sudo service cobblerd status
if [[ "$?" == "0" ]]; then
echo "cobblerd is running."
echo "cobblerd is running."
else
echo "cobblerd is not running"
exit 1
echo "cobblerd is not running"
exit 1
fi
# create repo
sudo mkdir -p /var/lib/cobbler/repo_mirror/ppa_repo
found_ppa_repo=0
# create centos repo
sudo mkdir -p /var/lib/cobbler/repo_mirror/centos_ppa_repo
found_centos_ppa_repo=0
for repo in $(cobbler repo list); do
if [ "$repo" == "ppa_repo" ]; then
found_ppa_repo=1
fi
if [ "$repo" == "centos_ppa_repo" ]; then
found_centos_ppa_repo=1
fi
done
if [ "$found_ppa_repo" == "0" ]; then
sudo cobbler repo add --mirror=/var/lib/cobbler/repo_mirror/ppa_repo --name=ppa_repo --mirror-locally=Y
if [[ "$?" != "0" ]]; then
echo "failed to add ppa_repo"
exit 1
if [ "$found_centos_ppa_repo" == "0" ]; then
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
echo "failed to add centos_ppa_repo"
exit 1
else
echo "centos_ppa_repo is added"
fi
else
echo "ppa_repo is added"
fi
else
echo "repo ppa_repo has already existed."
echo "repo centos_ppa_repo has already existed."
fi
# download packages
cd /var/lib/cobbler/repo_mirror/ppa_repo/
ppa_repo_packages="ntp-4.2.6p5-1.el6.${IMAGE_TYPE,,}.$IMAGE_ARCH.rpm
openssh-clients-5.3p1-94.el6.${IMAGE_ARCH}.rpm
iproute-2.6.32-31.el6.${IMAGE_ARCH}.rpm
wget-1.12-1.8.el6.${IMAGE_ARCH}.rpm
ntpdate-4.2.6p5-1.el6.${IMAGE_TYPE,,}.${IMAGE_ARCH}.rpm"
for f in $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/
cd /var/lib/cobbler/repo_mirror/centos_ppa_repo/
centos_ppa_repo_packages="
ntp-4.2.6p5-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_TYPE,,}.${CENTOS_IMAGE_ARCH}.rpm
openssh-clients-5.3p1-94.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
iproute-2.6.32-31.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
wget-1.12-1.8.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
ntpdate-4.2.6p5-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_TYPE,,}.${CENTOS_IMAGE_ARCH}.rpm"
for f in $centos_ppa_repo_packages; do
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
ppa_repo_rsyslog_packages="json-c-0.10-2.el6.$IMAGE_ARCH.rpm
libestr-0.1.9-1.el6.$IMAGE_ARCH.rpm
libgt-0.3.11-1.el6.$IMAGE_ARCH.rpm
liblogging-1.0.4-1.el6.$IMAGE_ARCH.rpm
rsyslog-7.6.3-1.el6.$IMAGE_ARCH.rpm"
for f in $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/
centos_ppa_repo_rsyslog_packages="
json-c-0.10-2.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
libestr-0.1.9-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
libgt-0.3.11-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
liblogging-1.0.4-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
rsyslog-7.6.3-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm"
for f in $centos_ppa_repo_rsyslog_packages; do
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
# download chef client for ppa repo
download $CHEF_CLIENT `basename $CHEF_CLIENT` copy /var/lib/cobbler/repo_mirror/ppa_repo/
# download chef client for centos ppa repo
download $CENTOS_CHEF_CLIENT `basename $CENTOS_CHEF_CLIENT` copy /var/lib/cobbler/repo_mirror/centos_ppa_repo/
# create centos repo
cd ..
sudo createrepo ppa_repo
sudo createrepo centos_ppa_repo
if [[ "$?" != "0" ]]; then
echo "failed to createrepo ppa_repo"
echo "failed to createrepo centos_ppa_repo"
exit 1
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
sudo cobbler reposync
if [[ "$?" != "0" ]]; then
echo "cobbler reposync failed"
exit 1
else
echo "cobbler repos are synced"
fi
# import cobbler distro
sudo mkdir -p /var/lib/cobbler/iso
download "$IMAGE_SOURCE" ${IMAGE_NAME}-${IMAGE_ARCH}.iso copy /var/lib/cobbler/iso/
sudo mkdir -p /mnt/${IMAGE_NAME}-${IMAGE_ARCH}
if [ $(mount | grep -c "/mnt/${IMAGE_NAME}-${IMAGE_ARCH} ") -eq 0 ]; then
sudo mount -o loop /var/lib/cobbler/iso/${IMAGE_NAME}-${IMAGE_ARCH}.iso /mnt/${IMAGE_NAME}-${IMAGE_ARCH}
if [[ "$?" != "0" ]]; then
echo "failed to mount image /mnt/${IMAGE_NAME}-${IMAGE_ARCH}"
exit 1
download "$CENTOS_IMAGE_SOURCE" ${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}.iso copy /var/lib/cobbler/iso/ || exit $?
sudo mkdir -p /mnt/${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}
if [ $(mount | grep -c "/mnt/${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH} ") -eq 0 ]; then
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
echo "failed to mount image /mnt/${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}"
exit 1
else
echo "/mnt/${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH} is mounted"
fi
else
echo "/mnt/${IMAGE_NAME}-${IMAGE_ARCH} is 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/${IMAGE_NAME}-${IMAGE_ARCH} has already mounted"
echo "/mnt/${UBUNTU_IMAGE_NAME}-${UBUNTU_IMAGE_ARCH} has already mounted"
fi
# add distro
found_distro=0
found_centos_distro=0
for distro in $(cobbler distro list); do
if [ "$distro" == "${IMAGE_NAME}-${IMAGE_ARCH}" ]; then
found_distro=1
fi
if [ "$distro" == "${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}" ]; then
found_centos_distro=1
fi
done
if [ "$found_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
if [[ "$?" != "0" ]]; then
echo "failed to import /mnt/${IMAGE_NAME}-${IMAGE_ARCH}"
exit 1
if [ "$found_centos_distro" == "0" ]; then
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
echo "failed to import /mnt/${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}"
exit 1
else
echo "/mnt/${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH} is imported"
fi
else
echo "/mnt/${IMAGE_NAME}-${IMAGE_ARCH} is imported"
echo "distro ${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH} has already existed"
sudo cobbler distro edit --name=${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH} --arch=${CENTOS_IMAGE_ARCH} --breed=redhat
if [[ "$?" != "0" ]]; then
echo "failed to edit distro ${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}"
exit 1
else
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 ${IMAGE_NAME}-${IMAGE_ARCH} has already existed"
sudo cobbler distro edit --name=${IMAGE_NAME}-${IMAGE_ARCH} --arch=${IMAGE_ARCH} --breed=redhat
if [[ "$?" != "0" ]]; then
echo "failed to edit distro ${IMAGE_NAME}-${IMAGE_ARCH}"
exit 1
else
echo "distro ${IMAGE_NAME}-${IMAGE_ARCH} is updated"
fi
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
# add profile
found_profile=0
centos_found_profile=0
for profile in $(cobbler profile list); do
if [ "$profile" == "${IMAGE_NAME}-${IMAGE_ARCH}" ]; then
found_profile=1
fi
if [ "$profile" == "${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}" ]; then
centos_found_profile=1
fi
done
if [ "$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
if [ "$centos_found_profile" == "0" ]; then
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
echo "failed to add profile ${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}"
exit 1
else
echo "profile ${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH} is added"
fi
else
echo "profile ${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH} has already existed."
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
echo "failed to edit profile ${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH}"
exit 1
else
echo "profile ${CENTOS_IMAGE_NAME}-${CENTOS_IMAGE_ARCH} is updated"
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 "failed to add profile ${IMAGE_NAME}-${IMAGE_ARCH}"
echo "cobbler reposync failed"
exit 1
else
echo "profile ${IMAGE_NAME}-${IMAGE_ARCH} is added"
echo "cobbler repos are synced"
fi
else
echo "profile $IMAGE_NAME 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
echo "Checking cobbler is OK"
sudo cobbler check
if [[ "$?" != "0" ]]; then
echo "failed to edit profile ${IMAGE_NAME}-${IMAGE_ARCH}"
echo "cobbler check failed"
exit 1
else
echo "profile ${IMAGE_NAME}-${IMAGE_ARCH} is updated"
fi
echo "cobbler check passed"
fi
echo "Cobbler configuration complete!"

View File

@ -55,28 +55,30 @@ sudo /opt/compass/bin/addcookbooks.py
if [[ "$?" != "0" ]]; then
echo "failed to add cookbooks"
exit 1
else
echo "cookbooks are added to chef server"
fi
sudo /opt/compass/bin/adddatabags.py
if [[ "$?" != "0" ]]; then
echo "failed to add databags"
exit 1
else
echo "databags are added to chef server"
fi
sudo /opt/compass/bin/addroles.py
if [[ "$?" != "0" ]]; then
echo "failed to add roles"
exit 1
fi
# 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
else
echo "roles are added to chef server"
fi
sudo /opt/compass/bin/refresh.sh
if [[ "$?" != "0" ]]; then
echo "failed to refresh compassd service
echo "failed to refresh compassd service"
exit 1
else
echo "compassed service is refreshed"
fi
sudo service httpd status
@ -87,6 +89,13 @@ else
echo "httpd has already started"
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
if [[ "$?" != "0" ]]; then
echo "redis is not started"
@ -102,3 +111,9 @@ if [[ "$?" != "0" ]]; then
else
echo "compassd has already started"
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
if [ "$tempest" == "true" ]; then
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
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
echo "failed to install yum dependency"
exit 1
@ -16,21 +20,37 @@ fi
sudo service ntpd stop
ntpdate 0.centos.pool.ntp.org
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
echo "failed to install easy install"
exit 1
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
sudo pip install -U setuptools
sudo pip install -U setuptools
if [[ "$?" != "0" ]]; then
echo "failed to install setuptools"
exit 1
fi
fi
sudo pip install -r $COMPASSDIR/requirements.txt
sudo pip install -r $COMPASSDIR/test-requirements.txt
sudo pip install -U -r $COMPASSDIR/requirements.txt
if [[ "$?" != "0" ]]; then
echo "failed to install pip packages"
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
fi

View File

@ -30,30 +30,49 @@ export CBLR_USER=${CBLR_USER:-}
export CBLR_PASSWD=${CBLR_PASSWD:-}
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_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_NAME=${IMAGE_NAME:-"${IMAGE_TYPE}-${IMAGE_VERSION}"}
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"}
# Currently the use of Javascript MVC is set to version 3.2.4
export JS_MVC=${JS_MVC:-"javascriptmvc-3.2.4"}
# 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_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_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
export CHEF_PASSWD=${CHEF_PASSWD:-"root1234"}
# 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 WEB_SOURCE=${WEB_SOURCE:-}
export ADAPTERS_SOURCE=${ADAPTERS_SOURCE:-}
export WEB_GERRIT_URL=${WEB_GERRIT_URL:-}
export ADAPTERS_GERRIT_URL=${ADAPTERS_GERRIT_URL:-}
# Set compass environment
export SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

View File

@ -30,28 +30,47 @@ export NAMESERVER_DOMAINS=ods.com
# the repo url
export WEB_SOURCE='http://git.openstack.org/stackforge'/compass-web
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
export CBLR_USER=cobbler
export CBLR_PASSWD=cobbler
# 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_OTHER=${IMAGE_TYPE_OTHER:-"el"}
export IMAGE_VERSION_MAJOR=${IMAGE_VERSION_MAJOR:-"6"}
export IMAGE_VERSION_MINOR=${IMAGE_VERSION_MINOR:-"5"}
export IMAGE_VERSION=${IMAGE_VERSION:-"${IMAGE_VERSION_MAJOR}.${IMAGE_VERSION_MINOR}"}
export IMAGE_NAME=${IMAGE_NAME:-"${IMAGE_TYPE}-${IMAGE_VERSION}"}
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"}
# Currently the use of Javascript MVC is set to version 3.2.4
export JS_MVC=javascriptmvc-3.2.4
# 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
export CHEF_PASSWD=root1234

View File

@ -24,21 +24,43 @@ exlock_now || exit 1
### BEGIN OF SCRIPT ###
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source $DIR/install.conf
### Change selinux security policy
echo 0 > /selinux/enforce
### Add epel repo
sudo rpm -q epel-release-6-8
sudo rpm -q epel-release
if [ "$?" != "0" ]; then
sudo rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm >& /dev/null
if [ "$?" != "0" ]; then
echo "failed to install epel"
exit 1
fi
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
echo "failed to install epel-release"
exit 1
else
echo "sucessfaully installed epel-release"
fi
else
echo "epel-release is already installed"
fi
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.
errtrap()
{
@ -52,6 +74,12 @@ fi
# Install figlet
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
while [ $1 ]; do
@ -72,7 +100,6 @@ ipaddr_convert()
}
# Load variables
source $DIR/install.conf
loadvars()
{
varname=${1,,}
@ -98,8 +125,8 @@ loadvars()
loadvars NIC "eth0"
sudo ifconfig $NIC
if [ $? -ne 0 ]; then
echo "There is no nic '$NIC' yet"
exit 1
echo "There is no nic '$NIC' yet"
exit 1
fi
sudo ifconfig $NIC | grep 'inet addr:' >& /dev/null
if [ $? -ne 0 ]; then
@ -138,6 +165,8 @@ ipcalc $IP_START -c
if [ $? -ne 0 ]; then
echo "ip start $IP_START format should be x.x.x.x"
exit 1
else
echo "ip start address is $IP_START"
fi
ip_start_net=$(ipcalc $IP_START $netmask -n |cut -f 2 -d '=')
if [[ "$ip_start_net" != "$netaddr" ]]; then
@ -171,31 +200,25 @@ if [ $? -ne 0 ]; then
fi
loadvars NAMESERVER_DOMAINS "ods.com"
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'
if [[ "$ADAPTERS_SOURCE" =~ https?:// ]]; then
loadvars ADAPTERS_GERRIT_URL 'https://review.openstack.org/stackforge/compass-adapters'
fi
echo "script dir: $SCRIPT_DIR"
echo "compass dir is $COMPASSDIR"
echo "Install the Dependencies"
source ${COMPASSDIR}/install/dependency.sh
source ${COMPASSDIR}/install/dependency.sh || exit $?
echo "Prepare the Installation"
source ${COMPASSDIR}/install/prepare.sh
source ${COMPASSDIR}/install/prepare.sh || exit $?
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"
source ${COMPASSDIR}/install/$PACKAGE_INSTALLER.sh
source ${COMPASSDIR}/install/$PACKAGE_INSTALLER.sh || exit $?
echo "Download and Setup Compass and related services"
source ${COMPASSDIR}/install/compass.sh
source ${COMPASSDIR}/install/compass.sh || exit $?
figlet -ctf slant Installation Complete!
echo -e "It takes\x1b[32m $SECONDS \x1b[0mseconds during the installation."

View File

@ -13,6 +13,8 @@ copy2dir()
if [ $? -ne 0 ]; then
echo "$destdir is not git repo"
rm -rf $destdir
else
echo "$destdir is git repo"
fi
cd -
fi
@ -33,6 +35,8 @@ copy2dir()
if [ $? -ne 0 ]; then
echo "failed to git clone $repo $destdir"
exit 1
else
echo "git clone $repo $destdir suceeded"
fi
cd $destdir
git reset --hard remotes/origin/$git_branch
@ -60,11 +64,15 @@ copy2dir()
if [ $? -ne 0 ]; then
echo "failed to copy $repo to $destdir"
exit 1
else
echo "copy $repo to $destdir succeeded"
fi
fi
if [[ ! -d $destdir && ! -L $destdir ]]; then
echo "$destdir doest not exist"
echo "$destdir does not exist"
exit 1
else
echo "$destdir is ready"
fi
cd $SCRIPT_DIR
}
@ -139,6 +147,7 @@ if [ -z $WEB_SOURCE ]; then
exit 1
fi
copy2dir "$WEB_SOURCE" "$WEB_HOME" "stackforge/compass-web"
if [ -z $ADAPTERS_SOURCE ]; then
echo "adpaters source $ADAPTERS_SOURCE is not set"
exit 1
@ -148,6 +157,10 @@ copy2dir "$ADAPTERS_SOURCE" "$ADAPTERS_HOME" "stackforge/compass-adapters"
if [ "$tempest" == "true" ]; then
if [[ ! -e /tmp/tempest ]]; then
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
git checkout grizzly-eol
else
@ -171,6 +184,7 @@ download()
echo "$package already exists"
else
if [[ "$url" =~ (http|https|ftp):// ]]; then
echo "downloading $url to /tmp/${package}"
wget -c --progress=bar:force -O /tmp/${package}.tmp $url
if [[ "$?" != "0" ]]; then
echo "failed to download $package"
@ -188,6 +202,7 @@ download()
fi
fi
if [[ "$action" == "install" ]]; then
echo "install /tmp/$package"
sudo rpm -Uvh /tmp/$package
if [[ "$?" != "0" ]]; then
echo "failed to install $package"
@ -196,45 +211,58 @@ download()
echo "$package is installed"
fi
elif [[ "$action" == "copy" ]]; then
echo "copy /tmp/$package to $destdir"
destdir=$4
sudo cp /tmp/$package $destdir
elif [[ "$action" == "unzip" ]]; then
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 unzip -o /tmp/$package /tmp/
pushd `pwd`
cd /tmp
sudo unzip -o /tmp/$package
popd
sudo cp -rf /tmp/$unzipped_package/. $destdir
fi
}
# 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
ppa_repo_packages="ntp-4.2.6p5-1.el6.${IMAGE_TYPE,,}.$IMAGE_ARCH.rpm
openssh-clients-5.3p1-94.el6.${IMAGE_ARCH}.rpm
iproute-2.6.32-31.el6.${IMAGE_ARCH}.rpm
wget-1.12-1.8.el6.${IMAGE_ARCH}.rpm
ntpdate-4.2.6p5-1.el6.${IMAGE_TYPE,,}.${IMAGE_ARCH}.rpm"
for f in $ppa_repo_packages
do
download ftp://rpmfind.net/linux/${IMAGE_TYPE,,}/${IMAGE_VERSION_MAJOR}/os/${IMAGE_ARCH}/Packages/$f $f
centos_ppa_repo_packages="
ntp-4.2.6p5-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_TYPE,,}.${CENTOS_IMAGE_ARCH}.rpm
openssh-clients-5.3p1-94.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
iproute-2.6.32-31.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
wget-1.12-1.8.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
ntpdate-4.2.6p5-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_TYPE,,}.${CENTOS_IMAGE_ARCH}.rpm"
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
ppa_repo_rsyslog_packages="json-c-0.10-2.el6.$IMAGE_ARCH.rpm
libestr-0.1.9-1.el6.$IMAGE_ARCH.rpm
libgt-0.3.11-1.el6.$IMAGE_ARCH.rpm
liblogging-1.0.4-1.el6.$IMAGE_ARCH.rpm
rsyslog-7.6.3-1.el6.$IMAGE_ARCH.rpm"
for f in $ppa_repo_rsyslog_packages
do
download http://rpms.adiscon.com/v7-stable/epel-6/${IMAGE_ARCH}/RPMS/$f $f
centos_ppa_repo_rsyslog_packages="
json-c-0.10-2.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
libestr-0.1.9-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
libgt-0.3.11-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
liblogging-1.0.4-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm
rsyslog-7.6.3-1.${CENTOS_IMAGE_TYPE_OTHER}${CENTOS_IMAGE_VERSION_MAJOR}.${CENTOS_IMAGE_ARCH}.rpm"
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
download "$IMAGE_SOURCE" ${IMAGE_NAME}-${IMAGE_ARCH}.iso
download $CHEF_CLIENT chef-client
download $CHEF_CLIENT `basename $CHEF_CLIENT` || exit $?
download $CENTOS_CHEF_CLIENT `basename $CENTOS_CHEF_CLIENT` || exit $?
download $UBUNTU_CHEF_CLIENT `basename $UBUNTU_CHEF_CLIENT` || exit $?
# 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
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
access_log none
vary_ignore_expire on
# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid
reload_into_ims on
# 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
read_ahead_gap 100 MB
@ -70,5 +68,4 @@ positive_dns_ttl 30 second
negative_dns_ttl 1 second
pipeline_prefetch on
vary_ignore_expire on
request_timeout 15 minute