instack-undercloud/scripts/instack-build-images

248 lines
6.2 KiB
Bash
Executable File

#!/bin/bash
set -eux
set -o pipefail
export image_build=${1:-"all"}
export INSTACK_ROOT=${INSTACK_ROOT:-"/usr/share"}
export ELEMENTS_PATH=${ELEMENTS_PATH:-"/usr/share/tripleo-image-elements:/usr/share/instack-undercloud"}
source "$INSTACK_ROOT"/instack-undercloud/instack-sourcerc
# Override TMP_DIR for image build.
# It defaults /tmp. But, /tmp is usually tmpfs mounted on Fedora, and dib will
# use a tmpfs on it's own if there is enough free RAM.
export TMP_DIR=${TMP_DIR:-/var/tmp}
export NODE_ARCH=${NODE_ARCH:-amd64}
# TODO(bnemec): This should use set-os-type from tripleo-incubator, but that's
# currently broken for rhel7.
if $(grep -Eqs 'Red Hat Enterprise Linux Server release 7' /etc/redhat-release); then
DEFAULT_DIST=rhel7
else
DEFAULT_DIST=fedora
fi
export NODE_DIST=${NODE_DIST:-$DEFAULT_DIST}
export DEPLOY_IMAGE_ELEMENT=${DEPLOY_IMAGE_ELEMENT:-deploy-ironic}
export DEPLOY_NAME=${DEPLOY_NAME:-deploy-ramdisk-ironic}
export DISCOVERY_IMAGE_ELEMENT=${DISCOVERY_IMAGE_ELEMENT:-discovery-ironic}
export DISCOVERY_NAME=${DISCOVERY_NAME:-discovery-ramdisk}
export DIB_COMMON_ELEMENTS=${DIB_COMMON_ELEMENTS:-""}
export DIB_COMMON_ELEMENTS="$DIB_COMMON_ELEMENTS \
element-manifest \
network-gateway \
"
export RHOS=${RHOS:-"0"}
export RHOS_RELEASE=${RHOS_RELEASE:-"0"}
if [[ "rhel7 centos7" =~ "$NODE_DIST" ]]; then
# Default filesystem type is XFS for RHEL 7
export FS_TYPE=${FS_TYPE:-xfs}
if [ "$RHOS" = "0" ]; then
export DIB_COMMON_ELEMENTS="$DIB_COMMON_ELEMENTS epel rdo-juno rdo-release"
elif [ ! "$RHOS_RELEASE" = "0" ]; then
export DIB_COMMON_ELEMENTS="$DIB_COMMON_ELEMENTS rhos-release"
fi
fi
export DELOREAN=${DELOREAN:-"0"}
if [ "$DELOREAN" = "1" ]; then
export DIB_COMMON_ELEMENTS="$DIB_COMMON_ELEMENTS delorean"
fi
export PACKAGES=${PACKAGES:-"1"}
if [ "$PACKAGES" = "1" ]; then
export DIB_COMMON_ELEMENTS="$DIB_COMMON_ELEMENTS tripleo-image-elements undercloud-package-install"
fi
export OVERCLOUD_CONTROL_DIB_EXTRA_ARGS=${OVERCLOUD_CONTROL_DIB_EXTRA_ARGS:-"\
baremetal \
base \
boot-stack \
ceilometer-agent-central \
ceilometer-agent-notification \
ceilometer-api \
ceilometer-collector \
cinder-api \
cinder-lio \
cinder-volume-nfs \
common-venv \
dhcp-all-interfaces \
haproxy \
horizon \
hosts \
keepalived \
mariadb-rpm \
neutron-network-node \
ntp \
os-collect-config \
pip-cache \
rabbitmq-server \
snmpd \
stable-interface-names \
stackuser \
swift-proxy \
swift-storage \
use-ephemeral \
"}
export OVERCLOUD_COMPUTE_DIB_EXTRA_ARGS=${OVERCLOUD_COMPUTE_DIB_EXTRA_ARGS:-"\
baremetal \
base \
common-venv \
dhcp-all-interfaces \
hosts \
neutron-openvswitch-agent \
nova-compute \
nova-kvm \
nfs-client \
ntp \
os-collect-config \
pip-cache \
pypi-openstack \
snmpd \
stable-interface-names \
stackuser \
use-ephemeral \
"}
export OVERCLOUD_CINDER_DIB_EXTRA_ARGS=${OVERCLOUD_CINDER_DIB_EXTRA_ARGS:-"\
baremetal \
base \
cinder-lio \
common-venv \
dhcp-all-interfaces \
hosts \
ntp \
os-collect-config \
pip-cache \
pypi-openstack \
snmpd \
stable-interface-names \
stackuser \
use-ephemeral \
"}
export OVERCLOUD_SWIFT_DIB_EXTRA_ARGS=${OVERCLOUD_SWIFT_DIB_EXTRA_ARGS:-"\
pip-cache \
pypi-openstack \
swift-storage \
os-collect-config \
baremetal \
base \
common-venv \
dhcp-all-interfaces \
hosts \
ntp \
snmpd \
stackuser \
stable-interface-names \
use-ephemeral \
os-refresh-config-reboot \
"}
function deploy-ramdisk {
if [ ! -f $DEPLOY_NAME.initramfs -o \
! -f $DEPLOY_NAME.kernel ]; then
ramdisk-image-create \
-a $NODE_ARCH \
-o $DEPLOY_NAME \
--ramdisk-element dracut-ramdisk \
$NODE_DIST $DEPLOY_IMAGE_ELEMENT \
$DIB_COMMON_ELEMENTS \
2>&1 | tee dib-deploy.log
fi
}
function discovery-ramdisk {
if [ ! -f $DISCOVERY_NAME.initramfs -o \
! -f $DISCOVERY_NAME.kernel ]; then
ramdisk-image-create \
-a $NODE_ARCH \
-o $DISCOVERY_NAME \
--ramdisk-element dracut-ramdisk \
$NODE_DIST $DISCOVERY_IMAGE_ELEMENT \
$DIB_COMMON_ELEMENTS \
2>&1 | tee dib-discovery.log
fi
}
function overcloud-control {
if [ ! -f overcloud-control.qcow2 ]; then
disk-image-create \
-a $NODE_ARCH \
-o overcloud-control \
$NODE_DIST \
$OVERCLOUD_CONTROL_DIB_EXTRA_ARGS \
$DIB_COMMON_ELEMENTS \
2>&1 | tee dib-overcloud-control.log
fi
}
function overcloud-compute {
if [ ! -f overcloud-compute.qcow2 ]; then
disk-image-create \
-a $NODE_ARCH \
-o overcloud-compute \
$NODE_DIST \
$OVERCLOUD_COMPUTE_DIB_EXTRA_ARGS \
$DIB_COMMON_ELEMENTS \
2>&1 | tee dib-overcloud-compute.log
fi
}
function overcloud-cinder-volume {
if [ ! -f overcloud-cinder-volume.qcow2 ]; then
disk-image-create \
-a $NODE_ARCH \
-o overcloud-cinder-volume \
$NODE_DIST \
$OVERCLOUD_CINDER_DIB_EXTRA_ARGS \
$DIB_COMMON_ELEMENTS \
2>&1 | tee dib-overcloud-cinder-volume.log
fi
}
function overcloud-swift-storage {
if [ ! -f overcloud-swift-storage.qcow2 ]; then
disk-image-create \
-a $NODE_ARCH \
-o overcloud-swift-storage \
$NODE_DIST \
$OVERCLOUD_SWIFT_DIB_EXTRA_ARGS \
$DIB_COMMON_ELEMENTS \
2>&1 | tee dib-overcloud-swift-storage.log
fi
}
function fedora-user {
if [ ! -f fedora-user.qcow2 ]; then
if [ -f ~/.cache/image-create/fedora-20.x86_64.qcow2 fedora-user.qcow2 ]; then
# Just copy the already downloaded Fedora cloud image as fedora-user.qcow2
cp ~/.cache/image-create/fedora-20.x86_64.qcow2 fedora-user.qcow2
else
# Download the image
curl -o fedora-user.qcow2 -L http://cloud.fedoraproject.org/fedora-20.x86_64.qcow2
fi
# The perms always seem to be wrong when copying out of the cache, so
# fix them
chmod 644 fedora-user.qcow2
fi
}
if [ "$image_build" = "all" ]; then
deploy-ramdisk
discovery-ramdisk
overcloud-control
overcloud-compute
overcloud-cinder-volume
overcloud-swift-storage
fedora-user
else
eval "$image_build"
fi