instack-undercloud/scripts/instack-install-undercloud-...

278 lines
8.9 KiB
Bash
Executable File

#!/bin/bash
set -eux
export INSTACK_ROOT=${INSTACK_ROOT:-"/usr/share"}
export ELEMENTS_PATH=${ELEMENTS_PATH:-"\
/usr/share/tripleo-image-elements:\
/usr/share/diskimage-builder/elements:\
/usr/share/instack-undercloud"}
export JSONFILE=${JSONFILE:-/usr/share/instack-undercloud/json-files/fedora-20-undercloud-packages.json}
source "$INSTACK_ROOT"/instack-undercloud/instack-sourcerc
sudo yum -y install git python-pip ccache
source /etc/profile.d/ccache.sh
mkdir -p $PIP_DOWNLOAD_CACHE
git config --global user.email "instack@example.com"
git config --global user.name "instack"
function cherry_pick {
local PROJ_NAME=$1
local REFSPEC=$2
pushd $PROJ_NAME
git fetch https://review.openstack.org/openstack/$PROJ_NAME "$REFSPEC"
git cherry-pick FETCH_HEAD
popd
}
function do_tripleo_source_installs {
if [ ! -d $INSTACK_ROOT/tripleo-image-elements/elements ]; then
git clone https://git.openstack.org/openstack/tripleo-image-elements
# Fix nested /etc/neutron/rootwrap.d in multiple runs
cherry_pick tripleo-image-elements refs/changes/35/128935/1
pushd tripleo-image-elements
if [ "$LKG" = "1" ]; then
git fetch origin $DIB_REPOREF_tripleo_image_elements
git reset --hard FETCH_HEAD
fi
# This patch is RDO specific, as such there is no upstream review for it.
# Change default swift ports
git fetch https://github.com/redhat-openstack/tripleo-image-elements
git cherry-pick 9a73b8a1cf8cdf23cbf065358532210c66dcdb40
popd
# https://review.openstack.org/#/c/128764/
cherry_pick tripleo-image-elements refs/changes/64/128764/1
# https://review.openstack.org/#/c/128769/
cherry_pick tripleo-image-elements refs/changes/69/128769/1
# disable keepalived custom policy on RHEL because it doesn't install
# https://bugzilla.redhat.com/show_bug.cgi?id=1151647
export NODE_DIST=${NODE_DIST:-fedora}
if [[ "$NODE_DIST" =~ "centos" || "$NODE_DIST" =~ "rhel" ]]; then
rm $INSTACK_ROOT/tripleo-image-elements/elements/selinux/custom-policies/tripleo-selinux-keepalived.te
fi
fi
if [ ! -d $INSTACK_ROOT/diskimage-builder ]; then
git clone https://git.openstack.org/openstack/diskimage-builder
pushd diskimage-builder
if [ "$LKG" = "1" ]; then
git fetch origin $DIB_REPOREF_diskimage_builder
git reset --hard FETCH_HEAD
fi
popd
fi
# tar is required if we want to run diskimage-builder
sudo yum install -y tar
if [ ! -d "$INSTACK_ROOT/dib-utils" ]; then
git clone https://git.openstack.org/openstack/dib-utils
fi
if [ ! -d $INSTACK_ROOT/instack-undercloud ]; then
git clone https://github.com/agroup/instack-undercloud
fi
if [ ! -d $INSTACK_ROOT/instack ]; then
git clone https://github.com/agroup/instack
fi
if [ ! -d $INSTACK_ROOT/os-cloud-config ]; then
git clone https://git.openstack.org/openstack/os-cloud-config
pushd os-cloud-config
if [ "$LKG" = "1" ]; then
git fetch origin $DIB_REPOREF_os_cloud_config
git reset --hard FETCH_HEAD
fi
popd
fi
if [ ! -d $INSTACK_ROOT/tripleo-incubator ]; then
git clone https://git.openstack.org/openstack/tripleo-incubator
pushd tripleo-incubator
if [ "$LKG" = "1" ]; then
git fetch origin $DIB_REPOREF_tripleo_incubator
git reset --hard FETCH_HEAD
fi
popd
fi
if [ ! -d $INSTACK_ROOT/tripleo-heat-templates ]; then
git clone https://git.openstack.org/openstack/tripleo-heat-templates
## Compute and controller templates without merge.py + Add converted version of block and object storage
#
# https://review.openstack.org/#/c/123100
cherry_pick tripleo-heat-templates refs/changes/00/123100/7
# https://review.openstack.org/#/c/123713/
cherry_pick tripleo-heat-templates refs/changes/13/123713/10
# https://review.openstack.org/#/c/126562
cherry_pick tripleo-heat-templates refs/changes/62/126562/2
fi
# Create a useful symlink for openstack-tripleo-heat-templates
# This simplifies the source vs package installs a bit so we can just use one path
ln -f -s $INSTACK_ROOT/tripleo-heat-templates $INSTACK_ROOT/openstack-tripleo-heat-templates
export DIB_REPOLOCATION_tripleo_heat_templates=$INSTACK_ROOT/tripleo-heat-templates
export DIB_INSTALLTYPE_tripleo_heat_templates=source
export TUSKAR_ROLE_DIRECTORY=/opt/stack/tripleo-heat-templates
# pip installs netaddr package as one of dependencies when
# installing instack-related projects bellow. Then later
# python-netaddr rpm is being installed and it fails on RHEL
# because it conflicts with pip's netaddr. Make sure python-netaddr
# rpm is installed first.
sudo yum -y install python-netaddr
pushd $INSTACK_ROOT/dib-utils
sudo pip install -U .
popd
pushd $INSTACK_ROOT/diskimage-builder
sudo pip install -U .
popd
pushd $INSTACK_ROOT/instack
sudo pip install -e .
popd
# Needed to compile os-cloud-config
sudo yum install -y libffi-devel gcc python-devel openssl-devel libxml2-devel libxslt-devel
pushd $INSTACK_ROOT/os-cloud-config
sudo pip install -e .
popd
# Must uninstall cmd2 otherwise, the package install will fail later on
sudo pip uninstall -y cmd2
}
if [ ! -d $INSTACK_ROOT/tuskar-ui ]; then
sudo git clone https://git.openstack.org/openstack/tuskar-ui $INSTACK_ROOT/tuskar-ui
fi
export DIB_REPOLOCATION_tuskar_ui=$INSTACK_ROOT/tuskar-ui
if [ "$INSTACK_TRIPLEO_SOURCE" = "1" ]; then
do_tripleo_source_installs
else
export TUSKAR_ROLE_DIRECTORY=/usr/share/openstack-tripleo-heat-templates
fi
# needed for semanage
sudo yum install -y policycoreutils-python
# ensure latest policy
sudo yum install -y selinux-policy
if [ "$RUN_INSTACK" -eq 0 ]; then
echo "Exiting without running instack."
exit 0
fi
if [ "$PACKAGES" = "1" -a "$DELOREAN" = "0" ]; then
if ! rpm -q rdo-release; then
sudo yum -y install http://team.virt.bos.redhat.com/openstack/openstack-juno/rdo-release-juno-1.noarch.rpm
fi
fi
if [[ "$JSONFILE" =~ "package" ]]; then
# Must delete any newer packages first
sudo yum -y erase openstack-ironic-common
sudo yum -y install \
https://athomas.fedorapeople.org/ironic/fedora20/openstack-ironic-api-2014.0923-2.noarch.rpm \
https://athomas.fedorapeople.org/ironic/fedora20/openstack-ironic-common-2014.0923-2.noarch.rpm \
https://athomas.fedorapeople.org/ironic/fedora20/openstack-ironic-conductor-2014.0923-2.noarch.rpm
sudo yum install -y libffi-devel gcc python-devel openssl-devel libxml2-devel libxslt-devel
# No update for python-paramiko yet, so update it via pip.
# https://bugzilla.redhat.com/show_bug.cgi?id=1139319
sudo pip install -U paramiko
# We also need newer eventlet. This is already packaged upstream in Juno,
# so no need to file a bug on this one.
sudo pip install -U eventlet
# This has been fixed in Delorean, just need to wait for a new Ironic build.
sudo /bin/bash -c "
cat > /etc/sudoers.d/ironic <<EOF
Defaults:ironic !requiretty
ironic ALL = (root) NOPASSWD: /usr/bin/ironic-rootwrap /etc/ironic/rootwrap.conf *
EOF
"
sudo chmod 0440 /etc/sudoers.d/ironic
# python-swiftclient requires python-futures
sudo yum -y install python-futures
# Must install python-heatclient from Delorean until we get an updated RDO
# package that has the feature to supply multiple environment files on the
# command line.
if ! rpm -q python-heatclient; then
sudo yum -y install http://209.132.178.33/repos/00/8f/008f5b67839ae03fa9a73ddc9a430c8312472e1a/python-heatclient-0.2.11.6-g6089d31.fc20.noarch.rpm
fi
# Must install python-ironicclient from Delorean until it is available in
# RDO.
if ! rpm -q python-ironicclient; then
sudo yum -y install http://209.132.178.33/repos/00/8f/008f5b67839ae03fa9a73ddc9a430c8312472e1a/python-ironicclient-0.3.0.10-g0ff9641.fc20.noarch.rpm
fi
fi
instack-install-undercloud
# Reset ownership of cache directory
# This is needed in order for instack-build-images to make changes to the cache
# $USER is not always set in a live cd building enviroment, so use || true
sudo -E chown -R $USER: $HOME/.cache/image-create || true
# svc-map requires PyYAML, need to submit this patch upstream
sudo yum -y install PyYAML
# Must erase NetworkManager, otherwise ifup called on the provisioning
# interface tries to use nmcli and that fails for some yet undetermined reason,
# so just delete NetworkManager for now.
sudo yum -y erase NetworkManager
# Must reinstall cmd2 as there is a package conflict with the pip install, so
# we have to reinstall it. Otherwise, "neturon net-show" during
# instack-deploy-overcloud fails.
sudo pip install -U cmd2
echo "$COMPLETION_MESSAGE"