instack-undercloud/scripts/instack-build-images

230 lines
5.7 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}
export NODE_DIST=${NODE_DIST:-"fedora"}
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 \
tripleo-image-elements"
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 undercloud-package-install rdo-juno"
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 \
python-swiftclient-python-futures \
"}
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 \
cinder-volume-nfs \
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 \
"}
if [[ "rhel7 centos7" =~ "$NODE_DIST" ]]; then
OVERCLOUD_CONTROL_DIB_EXTRA_ARGS="$OVERCLOUD_CONTROL_DIB_EXTRA_ARGS epel rdo-release"
OVERCLOUD_COMPUTE_DIB_EXTRA_ARGS="$OVERCLOUD_COMPUTE_DIB_EXTRA_ARGS epel rdo-release"
OVERCLOUD_CINDER_DIB_EXTRA_ARGS="$OVERCLOUD_CINDER_DIB_EXTRA_ARGS epel rdo-release"
OVERCLOUD_SWIFT_DIB_EXTRA_ARGS="$OVERCLOUD_SWIFT_DIB_EXTRA_ARGS epel rdo-release"
fi
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 \
$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
# Just copy the already downloaded Fedora cloud image as fedora-user.qcow2
cp ~/.cache/image-create/fedora-20.x86_64.qcow2 fedora-user.qcow2
# 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