From bbdd8ce3b0bcace781d8a914c060661b4ff3eaa3 Mon Sep 17 00:00:00 2001 From: qingyu Date: Fri, 13 Jan 2017 18:17:18 -0500 Subject: [PATCH] added scripts for using compass offline_repo -added template conf file for pip&easy_install -remove installation of epel and remi-safe repo, related pakcages are moved to compass_install repo Change-Id: Idded23eb60783e78763aa52d2801ee6052abeb7c --- .gitignore | 2 +- install/env.conf | 2 +- install/install.conf | 34 ++++++++++------ install/install.sh | 69 +++++++++++++++++--------------- install/offline_repo.sh | 61 ++++++++++++++++++++++++++++ install/prepare.sh | 10 +++-- install/standalone_server.conf | 51 ++++++++++++++++++++++-- install/standalone_server.sh | 70 +++++++++++++++++---------------- misc/pip_localrepo.conf | 3 ++ misc/pydistutils_localrepo.conf | 3 ++ 10 files changed, 220 insertions(+), 85 deletions(-) create mode 100755 install/offline_repo.sh create mode 100644 misc/pip_localrepo.conf create mode 100644 misc/pydistutils_localrepo.conf diff --git a/.gitignore b/.gitignore index cd2753a8..34029733 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,7 @@ # temp files install/env.sh - +install/env.conf # Packages *.egg *.egg-info diff --git a/install/env.conf b/install/env.conf index 3d69abad..b92fbaf7 100755 --- a/install/env.conf +++ b/install/env.conf @@ -1,4 +1,4 @@ -NIC=${NIC:-eth1} +NIC=${NIC:-ens224} IPADDR=${IPADDR:-10.1.10.15} NETMASK=${NETMASK:-255.255.255.0} WEB_SOURCE=${WEB_SOURCE:-http://git.openstack.org/openstack/compass-web} diff --git a/install/install.conf b/install/install.conf index 6cbe6bc7..2f641433 100755 --- a/install/install.conf +++ b/install/install.conf @@ -2,32 +2,35 @@ # Config File for Compass Installer # ##################################### # Agent or Fullserver -export FULL_COMPASS_SERVER="true" +export FULL_COMPASS_SERVER="false" +#url of compass offline repo +#export REPO="http://10.145.250.80:9999" # User Email export USER_EMAIL="test@huawei.com" # User Password export USER_PASSWORD= # Compass Server Address, required if installing agent -export COMPASS_API_SERVER="c.stack360.io" +export COMPASS_API_SERVER="10.145.250.32" # Release tag export RELEASE_TAG="colorado.3.0" # OS_INSTALLER indicates the tool for OS provisioning, default is 'cobbler'. export OS_INSTALLER="cobbler" - +export tempest="false" # PACKAGE_INSTALLER indicates the tool for Package provisioning, default is 'chef'. export PACKAGE_INSTALLER="package" # set remi release url # export ATOMIC=${ATOMIC:-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} # export REMI=${REMI:-http://rpms.famillecollet.com/enterprise/remi-release-6.rpm} -export REMI="http://rpms.famillecollet.com/enterprise/remi-release-7.rpm" +#export REMI="http://rpms.famillecollet.com/enterprise/remi-release-7.rpm" -export EPEL="https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm" +#export EPEL="https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm" + +#export MYSQL="mysql-community-release-el7-5.noarch.rpm" -export MYSQL="http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm" export OPENSTACK_ANSIBLE_MODULE="https://github.com/openstack-ansible/openstack-ansible-modules.git" - +#export OPENSTACK_ANSIBLE_MODULE="${REPO}/openstack-ansible-modules" # External network config for access remote compass server # External network NIC export PUBLIC_NIC="eth0" @@ -80,16 +83,25 @@ export IMAGE_VERSION="${IMAGE_VERSION_MAJOR}.${IMAGE_VERSION_MINOR}" export IMAGE_NAME="${IMAGE_TYPE}-${IMAGE_VERSION}" export IMAGE_ARCH="x86_64" + export CENTOS_7_2_IMAGE_SOURCE="http://205.177.226.237:9999/CentOS-7-x86_64-Minimal-1511.iso" export UBUNTU_14_04_03_IMAGE_SOURCE="http://205.177.226.237:9999/ubuntu-14.04.3-server-amd64.iso" export CENTOS_7_2_PPA_REPO_SOURCE="http://205.177.226.237:9999/centos7-juno-ppa.tar.gz" export UBUNTU_14_04_03_PPA_REPO_SOURCE="http://205.177.226.237:9999/trusty-mitaka-ppa.tar.gz" export PIP_PACKAGES="http://205.177.226.237:9999/pip.tar.gz" -export EXTRA_PACKAGES="http://205.177.226.237:9999/packages.tar.gz" + +#offline repo for iso and ppa +#export CENTOS_7_2_IMAGE_SOURCE="${REPO}/CentOS-7-x86_64-Minimal-1511.iso" +#export UBUNTU_14_04_03_IMAGE_SOURCE="${REPO}/ubuntu-14.04.3-server-amd64.iso" +#export CENTOS_7_2_PPA_REPO_SOURCE="${REPO}/centos7-juno-ppa.tar.gz" +#export UBUNTU_14_04_03_PPA_REPO_SOURCE="${REPO}/trusty-mitaka-ppa.tar.gz" +#export PIP_PACKAGES="${REPO}/pip.tar.gz" +#export EXTRA_PACKAGES="${REPO}/packages.tar.gz" export COBBLER_PASSWORD="cobbler" -export COBBLER_LOADERS_SOURCE="https://s3-us-west-1.amazonaws.com/compass-local-repo/loaders.tar.gz" +export COBBLER_LOADERS_SOURCE="http://205.177.226.237:9999/loaders.tar.gz" +#export COBBLER_LOADERS_SOURCE="${REPO}/loaders.tar.gz" export COBBLER_LOADERS_SOURCE_ASIA="http://huawei-repo.uubright.com/repos/compass/loaders.tar.gz" # Currently the use of Javascript MVC is set to version 3.2.4 @@ -108,8 +120,8 @@ export CHEF_PASSWD="root1234" export WEB_HOME="/tmp/web" export ADAPTERS_HOME="/tmp/adapter/deploy/adapters" export ADAPTERS_DEST="/tmp/adapter" -export WEB_SOURCE= -export ADAPTERS_SOURCE= +#export WEB_SOURCE="${REPO}/compass-web" +#export ADAPTERS_SOURCE="${REPO}/compass4nfv" # Set compass environment export SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) diff --git a/install/install.sh b/install/install.sh index a29d5fe4..6521bcd0 100755 --- a/install/install.sh +++ b/install/install.sh @@ -150,40 +150,47 @@ source $DIR/install.conf ### Change selinux security policy sudo setenforce 0 sudo sed -i 's/enforcing/disabled/g' /etc/selinux/config + +###configure compass_install.repo +rm -rf /etc/yum.repos.d/compass_install.repo 2>/dev/null +cp ${COMPASSDIR}/misc/compass_install.repo /etc/yum.repos.d/ +yum clean all + + ### Add epel repo -sudo rpm -q epel-release -if [ "$?" != "0" ]; then - sudo rpm -Uvh $EPEL - 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 +#sudo rpm -q epel-release +#if [ "$?" != "0" ]; then +# sudo rpm -Uvh $EPEL +# 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 +#sed -i 's/^mirrorlist=https/mirrorlist=http/g' /etc/yum.repos.d/epel.repo -sudo rpm -q atomic-release -if [ "$?" == "0" ]; then - sudo rpm -e atomic-release -fi +#sudo rpm -q atomic-release +#if [ "$?" == "0" ]; then +# sudo rpm -e atomic-release +#fi ### Add remi repo -sudo rpm -q remi-release -if [ "$?" != "0" ]; then - sudo rpm -Uvh $REMI >& /dev/null - if [ "$?" != "0" ]; then - echo "failed to install remi-release" - exit 1 - else - echo "successfully installed remi-release" - fi -else - echo "remi-release is already installed" -fi +#sudo rpm -q remi-release +#if [ "$?" != "0" ]; then +# sudo rpm -Uvh $REMI >& /dev/null +# if [ "$?" != "0" ]; then +# echo "failed to install remi-release" +# exit 1 +# else +# echo "successfully installed remi-release" +# fi +#else +# echo "remi-release is already installed" +#fi # sed -i 's/^mirrorlist=https/mirrorlist=http/g' /etc/yum.repos.d/atomic.repo @@ -321,8 +328,8 @@ export ADAPTERS_SOURCE=${ADAPTERS_SOURCE:-"https://gerrit.opnfv.org/gerrit/compa echo "set the iptables' rules so that the openstack hosts installed can access remote compass through agent server" set_iptables ${PUBLIC_IP} ${IPADDR} ${NETMASK} -rm -rf /etc/yum.repos.d/compass_install.repo 2>/dev/nullcp -cp ${COMPASSDIR}/misc/compass_install.repo /etc/yum.repos.d/ +#rm -rf /etc/yum.repos.d/compass_install.repo 2>/dev/nullcp +#cp ${COMPASSDIR}/misc/compass_install.repo /etc/yum.repos.d/ echo "script dir: $SCRIPT_DIR" echo "compass dir is $COMPASSDIR" diff --git a/install/offline_repo.sh b/install/offline_repo.sh new file mode 100755 index 00000000..905b5465 --- /dev/null +++ b/install/offline_repo.sh @@ -0,0 +1,61 @@ +export SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +export COMPASSDIR=${SCRIPT_DIR}/.. + +#disable yum base official repo +mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup + + +cat << 'EOF' > /etc/yum.repos.d/CentOS-Base.repo +# CentOS-Base.repo +# +# The mirror system uses the connecting IP address of the client and the +# update status of each mirror to pick mirrors that are updated to and +# geographically close to the client. You should use this for CentOS updates +# unless you are manually picking other mirrors. +# +# If the mirrorlist= does not work for you, as a fall back you can try the +# remarked out baseurl= line instead. +# +# +[base] +name=CentOS-$releasever - Base - 163.com +#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os +baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/ +gpgcheck=1 +gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 +enabled=0 +#released updates +[updates] +name=CentOS-$releasever - Updates - 163.com +#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates +baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/ +gpgcheck=1 +gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 +enabled=0 +#additional packages that may be useful +[extras] +name=CentOS-$releasever - Extras - 163.com +#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras +baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/ +gpgcheck=1 +gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 +enabled=0 +#additional packages that extend functionality of existing packages +[centosplus] +name=CentOS-$releasever - Plus - 163.com +baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/ +gpgcheck=1 +enabled=0 +gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 +EOF + +yum clean all + +#change pip repo +rm -rf /root/.pip +mkdir -p /root/.pip +rm -f /root/.pydistutils.cfg +cp ${COMPASSDIR}/misc/pip_localrepo.conf /root/.pip/pip.conf +cp ${COMPASSDIR}/misc/pydistutils_localrepo.conf /root/.pydistutils.cfg + + diff --git a/install/prepare.sh b/install/prepare.sh index 76318038..6a941b05 100755 --- a/install/prepare.sh +++ b/install/prepare.sh @@ -168,11 +168,13 @@ if [[ "$?" != "0" ]]; then fi local_branch=$(echo ${remote_branch} | sed -e 's/origin\///g') -if [ -z $WEB_SOURCE ]; then - echo "web source $WEB_SOURCE is not set" - exit 1 +if [ "FULL_COMPASS_SERVER" == "true" ]; then + if [ -z $WEB_SOURCE ]; then + echo "web source $WEB_SOURCE is not set" + exit 1 + fi + copy2dir "$WEB_SOURCE" "$WEB_HOME" || exit $? fi -copy2dir "$WEB_SOURCE" "$WEB_HOME" || exit $? if [ -z $ADAPTERS_SOURCE ]; then echo "adpaters source $ADAPTERS_SOURCE is not set" diff --git a/install/standalone_server.conf b/install/standalone_server.conf index 3e5abfff..1c965581 100755 --- a/install/standalone_server.conf +++ b/install/standalone_server.conf @@ -1,15 +1,18 @@ ############################################# # Config File for Standalone Compass Server # ############################################# -export REMI="http://rpms.famillecollet.com/enterprise/remi-release-7.rpm" +#export REPO=http://127.0.0.1:9999 +#export REMI="http://rpms.famillecollet.com/enterprise/remi-release-7.rpm" -export EPEL="https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm" +#export EPEL="https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm" -export MYSQL="mysql-community-release-el7-5.noarch.rpm" +#export MYSQL="mysql-community-release-el7-5.noarch.rpm" # Compass web related variables export WEB_HOME="/tmp/web" -export WEB_SOURCE= +#uncomment this field if using compass-web repo in offline repo +#export WEB_SOURCE="${REPO}/compass-web" + #set compass environment export SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) @@ -17,9 +20,49 @@ export COMPASSDIR=${SCRIPT_DIR}/.. export TESTMODE="False" # Set Local Repo sources +#export LOCAL_REPO_US="https://s3-us-west-1.amazonaws.com/compass-local-repo" export LOCAL_REPO_US="https://s3-us-west-1.amazonaws.com/compass-local-repo" export LOCAL_REPO_HUAWEI="http://huawei-repo.uubright.com/repos/compass" # package hosting sources export PIP_PACKAGES="http://205.177.226.237:9999/pip.tar.gz" +#export PIP_PACKAGES="${REPO}/pip.tar.gz" export EXTRA_PACKAGES="http://205.177.226.237:9999/packages.tar.gz" +#export EXTRA_PACKAGES="${REPO}/packages.tar.gz" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/install/standalone_server.sh b/install/standalone_server.sh index 3c2b1fb5..d1e5ad8a 100755 --- a/install/standalone_server.sh +++ b/install/standalone_server.sh @@ -73,40 +73,46 @@ source $DIR/install_func.sh sudo setenforce 0 sudo sed -i 's/enforcing/disabled/g' /etc/selinux/config +###configure compass_install repo +rm -rf /etc/yum.repos.d/compass_install.repo 2>/dev/null +cp ${COMPASSDIR}/misc/compass_install.repo /etc/yum.repos.d/ + +yum clean all + ### Add epel repo -sudo rpm -q epel-release -if [ "$?" != "0" ]; then - sudo rpm -Uvh $EPEL - 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 +#sudo rpm -q epel-release +#if [ "$?" != "0" ]; then +# sudo rpm -Uvh $EPEL +# 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 +#sed -i 's/^mirrorlist=https/mirrorlist=http/g' /etc/yum.repos.d/epel.repo -sudo rpm -q atomic-release -if [ "$?" == "0" ]; then - sudo rpm -e atomic-release -fi +#sudo rpm -q atomic-release +#if [ "$?" == "0" ]; then +# sudo rpm -e atomic-release +#fi ### Add remi repo -sudo rpm -q remi-release -if [ "$?" != "0" ]; then - sudo rpm -Uvh $REMI >& /dev/null - if [ "$?" != "0" ]; then - echo "failed to install remi-release" - exit 1 - else - echo "successfully installed remi-release" - fi -else - echo "remi-release is already installed" -fi +#sudo rpm -q remi-release +#if [ "$?" != "0" ]; then +# sudo rpm -Uvh $REMI >& /dev/null +# if [ "$?" != "0" ]; then +# echo "failed to install remi-release" +# exit 1 +# else +# echo "successfully installed remi-release" +# fi +#else +# echo "remi-release is already installed" +#fi ### Trap any error code with related filename and line. errtrap() @@ -127,11 +133,9 @@ sudo yum update -y # assign all necessary values. export WEB_SOURCE=${WEB_SOURCE:-"http://git.openstack.org/openstack/compass-web"} -rm -rf /etc/yum.repos.d/compass_install.repo 2>/dev/nullcp -cp ${COMPASSDIR}/misc/compass_install.repo /etc/yum.repos.d/ # Start: install required packages and dependencies -sudo yum --enablerepo=compass_install install -y $MYSQL +#sudo yum --enablerepo=compass_install install -y $MYSQL sudo yum --enablerepo=compass_install --nogpgcheck install -y rsyslog logrotate ntp python python-devel git wget syslinux amqp mod_wsgi httpd bind rsync yum-utils gcc unzip openssl openssl098e ca-certificates mysql-devel mysql-server mysql MySQL-python python-virtualenv python-setuptools python-pip bc libselinux-python libffi-devel openssl-devel rabbitmq-server sudo yum --setopt=tsflags=noscripts -y remove redis sudo yum --enablerepo=compass_install --nogpgcheck install -y redis @@ -391,7 +395,7 @@ else echo "compass package is installed in virtualenv under current dir" fi -udo sed -i "s/\$ipaddr/$IPADDR/g" /etc/compass/setting +sudo sed -i "s/\$ipaddr/$IPADDR/g" /etc/compass/setting sudo sed -i "s/\$hostname/$HOSTNAME/g" /etc/compass/setting sudo sed -i "s/\$gateway/$OPTION_ROUTER/g" /etc/compass/setting domains=$(echo $NAMESERVER_DOMAINS | sed "s/,/','/g") diff --git a/misc/pip_localrepo.conf b/misc/pip_localrepo.conf new file mode 100644 index 00000000..e63bb9b5 --- /dev/null +++ b/misc/pip_localrepo.conf @@ -0,0 +1,3 @@ +[global] +index-url=http://127.0.0.1:9999/pip/simple +trusted-host=127.0.0.1 diff --git a/misc/pydistutils_localrepo.conf b/misc/pydistutils_localrepo.conf new file mode 100644 index 00000000..288367ed --- /dev/null +++ b/misc/pydistutils_localrepo.conf @@ -0,0 +1,3 @@ +[easy_install] +index-url=http://127.0.0.1:9999/pip/simple +