instack-undercloud/scripts/instack-install-undercloud
Ben Nemec f2f19c4842 set +x before outputting user messages
instack-virt-setup is set -x, which makes the user messages at
the end a bit difficult to parse.  Add a set +x before echoing
them to clean up the output a bit.

Change-Id: I3189ccfb495371d74801b86f02585c1afdbbef5a
2015-03-23 14:34:50 -05:00

146 lines
5.5 KiB
Bash
Executable File

#!/bin/bash
set -eu
mkdir -p ~/.instack
LOGFILE=~/.instack/install-undercloud.log
exec > >(tee $LOGFILE)
exec 2>&1
echo "Running $0"
# We must do this until tripleo-puppet-elements is packaged
export DIB_INSTALLTYPE_puppet_modules=source
# Attempt to be smart about detecting the path to the json files.
JSONFILEDIR=/usr/share/instack-undercloud/json-files
if [ ! -d "$JSONFILEDIR" ]; then
JSONFILEDIR=$(dirname $0)/../json-files
fi
if $(grep -Eqs 'Red Hat Enterprise Linux' /etc/redhat-release); then
export NODE_DIST=${NODE_DIST:-rhel7}
export JSONFILE=${JSONFILE:-$JSONFILEDIR/rhel-7-undercloud-packages.json}
export REG_METHOD=disable
export REG_HALT_UNREGISTER=1
elif $(grep -Eqs 'CentOS' /etc/redhat-release); then
export NODE_DIST=${NODE_DIST:-centos7}
export JSONFILE=${JSONFILE:-$JSONFILEDIR/centos-7-undercloud-packages.json}
elif $(grep -Eqs 'Fedora' /etc/redhat-release); then
export NODE_DIST=${NODE_DIST:-fedora}
echo "Fedora not currently supported"
exit 1
else
echo "Could not detect distritubion from /etc/redhat-release!"
exit 1
fi
# Attempt to be smart about detecting the patch to the instack-undercloud
# elements
INSTACKUNDERCLOUDELEMENTS=/usr/share/instack-undercloud
if [ ! -d $INSTACKUNDERCLOUDELEMENTS ]; then
INSTACKUNDERCLOUDELEMENTS=$(dirname $0)/../elements
fi
TRIPLEOPUPPETELEMENTS=/usr/share/tripleo-puppet-elements
if [ ! -d $TRIPLEOPUPPETELEMENTS ]; then
# Assume it's checked out in the current directory
TRIPLEOPUPPETELEMENTS=$PWD/tripleo-puppet-elements/elements
fi
export ELEMENTS_PATH=${ELEMENTS_PATH:-"\
$TRIPLEOPUPPETELEMENTS:\
$INSTACKUNDERCLOUDELEMENTS:\
/usr/share/tripleo-image-elements:\
/usr/share/diskimage-builder/elements"}
echo "Sourcing answers file from instack.answers..."
source ~/instack.answers
# Munge up LOCAL_IP. Keep in sync with instack-apply-config
export PUBLIC_INTERFACE_IP="$LOCAL_IP"
export LOCAL_IP="${LOCAL_IP%/*}"
export IMAGE_PATH
export LOCAL_INTERFACE
export MASQUERADE_NETWORK
export DHCP_START
export DHCP_END
export NETWORK_CIDR
export NETWORK_GATEWAY
export DISCOVERY_INTERFACE
export DISCOVERY_IPRANGE
export DISCOVERY_PXEIP
# Reuse any existing defined passwords. This is important since any users
# defined in Keystone already have passwords set. So we don't want to generate
# new ones that end up as values in configuration files.
if sudo bash -c '[[ -f /root/tripleo-undercloud-passwords ]]'; then
source <(sudo cat /root/tripleo-undercloud-passwords)
fi
export UNDERCLOUD_HEAT_STACK_DOMAIN_ADMIN_PASSWORD=${UNDERCLOUD_HEAT_STACK_DOMAIN_ADMIN_PASSWORD:-$(tripleo os-make-password)}
export UNDERCLOUD_RABBIT_COOKIE=${UNDERCLOUD_RABBIT_COOKIE:-$(tripleo os-make-password)}
export UNDERCLOUD_RABBIT_PASSWORD=${UNDERCLOUD_RABBIT_PASSWORD:-guest}
export UNDERCLOUD_RABBIT_USERNAME=${UNDERCLOUD_RABBIT_USERNAME:-guest}
export UNDERCLOUD_SWIFT_HASH_SUFFIX=${UNDERCLOUD_SWIFT_HASH_SUFFIX:-$(tripleo os-make-password)}
export UNDERCLOUD_ADMIN_PASSWORD=${UNDERCLOUD_ADMIN_PASSWORD:-$(tripleo os-make-password)}
export UNDERCLOUD_ADMIN_TOKEN=${UNDERCLOUD_ADMIN_TOKEN:-$(tripleo os-make-password)}
export UNDERCLOUD_CEILOMETER_METERING_SECRET=${UNDERCLOUD_CEILOMETER_METERING_SECRET:-$(tripleo os-make-password)}
export UNDERCLOUD_CEILOMETER_PASSWORD=${UNDERCLOUD_CEILOMETER_PASSWORD:-$(tripleo os-make-password)}
export UNDERCLOUD_CEILOMETER_SNMPD_PASSWORD=${UNDERCLOUD_CEILOMETER_SNMPD_PASSWORD:-$(tripleo os-make-password)}
export UNDERCLOUD_CEILOMETER_SNMPD_USER=${UNDERCLOUD_CEILOMETER_SNMPD_USER:-$(tripleo os-make-password)}
export UNDERCLOUD_GLANCE_PASSWORD=${UNDERCLOUD_GLANCE_PASSWORD:-$(tripleo os-make-password)}
export UNDERCLOUD_HEAT_PASSWORD=${UNDERCLOUD_HEAT_PASSWORD:-$(tripleo os-make-password)}
export UNDERCLOUD_HORIZON_SECRET_KEY=${UNDERCLOUD_HORIZON_SECRET_KEY:-$(tripleo os-make-password)}
export UNDERCLOUD_IRONIC_PASSWORD=${UNDERCLOUD_IRONIC_PASSWORD:-$(tripleo os-make-password)}
export UNDERCLOUD_NEUTRON_PASSWORD=${UNDERCLOUD_NEUTRON_PASSWORD:-$(tripleo os-make-password)}
export UNDERCLOUD_NOVA_PASSWORD=${UNDERCLOUD_NOVA_PASSWORD:-$(tripleo os-make-password)}
export UNDERCLOUD_SWIFT_PASSWORD=${UNDERCLOUD_SWIFT_PASSWORD:-$(tripleo os-make-password)}
export UNDERCLOUD_TUSKAR_PASSWORD=${UNDERCLOUD_TUSKAR_PASSWORD:-$(tripleo os-make-password)}
sudo -E instack \
-p $ELEMENTS_PATH \
-j $JSONFILE
RUN_ORC=${RUN_ORC:-"1"}
export INSTACK_ROOT=${INSTACK_ROOT:-""}
if [ "$RUN_ORC" = "1" ]; then
sudo INSTACK_ROOT=$INSTACK_ROOT IMAGE_PATH=$IMAGE_PATH os-refresh-config
# generate ssh authentication keys if they don't exist
if [ ! -f ~/.ssh/id_rsa ]; then
ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
fi
source <(sudo cat /root/stackrc)
if ! nova keypair-show default 2>/dev/null; then
tripleo user-config
fi
fi
# This is owned by root, which can break later image builds as a regular user
sudo rm -f /tmp/svc-map-services
export COMPLETION_MESSAGE=${COMPLETION_MESSAGE:-"\
#############################################################################
instack-install-undercloud complete.
The file containing this installation's passwords is at
/root/tripleo-undercloud-passwords.
There is also a stackrc file at /root/stackrc.
These files are needed to interact with the OpenStack services, and should be
secured. For convenience, they can be copied to the current directory:
sudo cp /root/tripleo-undercloud-passwords .
sudo cp /root/stackrc .
#############################################################################"}
echo "$COMPLETION_MESSAGE"