MT#17213 Add support of Sipwise Hiera Rescue drive on USB or CDROM

New mode 'auto' is introduced, we are trying to find any device with
label "Sipwise Hiera Rescue *" and mount it using appropriate device type.

Also switch to function die() on error to set set_deploy_status=error
properly (otherwise jenkins doesn't detect error on autotests).

Change-Id: I0a9900b0e8edcb1e12f09caaf66e94a49b8ac863
changes/26/4726/1
Alexander Lutay 9 years ago
parent 4040bfe00d
commit 44cda64460

@ -49,8 +49,9 @@ PUPPET_GIT_REPO=''
PUPPET_GIT_BRANCH=master PUPPET_GIT_BRANCH=master
PUPPET_LOCAL_GIT="${TARGET}/tmp/puppet.git" PUPPET_LOCAL_GIT="${TARGET}/tmp/puppet.git"
PUPPET_INIT_HIERA=false PUPPET_INIT_HIERA=false
PUPPET_RESCUE_DRIVE="/dev/null" PUPPET_RESCUE_DRIVE="none"
PUPPET_RESCUE_PATH="/mnt/cdrom" PUPPET_RESCUE_PATH="/mnt/rescue_drive"
PUPPET_RESCUE_LABEL="Sipwise Hiera Rescue *"
RESTART_NETWORK=true RESTART_NETWORK=true
INTERACTIVE=false INTERACTIVE=false
DHCP=false DHCP=false
@ -1730,8 +1731,7 @@ EOT
NGCP_SERVICES_FILE="${TARGET}/usr/share/ngcp-system-tools/ngcp.inc" NGCP_SERVICES_FILE="${TARGET}/usr/share/ngcp-system-tools/ngcp.inc"
if ! [ -r "$NGCP_SERVICES_FILE" ]; then if ! [ -r "$NGCP_SERVICES_FILE" ]; then
echo "Error: File $NGCP_SERVICES_FILE not found. Exiting." >&2 die "Error: File $NGCP_SERVICES_FILE not found. Exiting."
exit 1
fi fi
# make sure services are stopped # make sure services are stopped
@ -2175,8 +2175,7 @@ puppet_install_from_git () {
echo "Cloning Puppet git repository from '${PUPPET_GIT_REPO}' to '${PUPPET_LOCAL_GIT}' (branch '${PUPPET_GIT_BRANCH}')" echo "Cloning Puppet git repository from '${PUPPET_GIT_REPO}' to '${PUPPET_LOCAL_GIT}' (branch '${PUPPET_GIT_BRANCH}')"
if ! git clone --depth 1 -b "${PUPPET_GIT_BRANCH}" "${PUPPET_GIT_REPO}" "${PUPPET_LOCAL_GIT}" ; then if ! git clone --depth 1 -b "${PUPPET_GIT_BRANCH}" "${PUPPET_GIT_REPO}" "${PUPPET_LOCAL_GIT}" ; then
echo "ERROR: Cannot clone git repository, see the error above, cannot continue!" >&2 die "ERROR: Cannot clone git repository, see the error above, cannot continue!"
exit 1
fi fi
echo "Deploying Puppet config from Git repository to ${TARGET}/etc/puppet/" echo "Deploying Puppet config from Git repository to ${TARGET}/etc/puppet/"
@ -2185,21 +2184,34 @@ puppet_install_from_git () {
rm -rf "${PUPPET_LOCAL_GIT}" rm -rf "${PUPPET_LOCAL_GIT}"
case "${PUPPET_RESCUE_DRIVE}" in case "${PUPPET_RESCUE_DRIVE}" in
/dev/cdrom) auto)
echo "Copying Hiera rescue data from drive '${PUPPET_RESCUE_DRIVE}' (mounted into '${PUPPET_RESCUE_PATH}')" echo "Searching for Hiera rescue device by label '${PUPPET_RESCUE_LABEL}'..."
PUPPET_RESCUE_DRIVE=$(blkid | grep -E "LABEL=\"${PUPPET_RESCUE_LABEL}" | head -1 | awk -F: '{print $1}')
if [ ! -n "${PUPPET_RESCUE_DRIVE}" ] ; then
die "ERROR: No USB device found matching label '${PUPPET_RESCUE_LABEL}', cannot continue!"
fi
local device_type
device_type=$(blkid | grep -E "LABEL=\"${PUPPET_RESCUE_LABEL}" | head -1 | sed 's/.*TYPE="\(.*\)".*/\1/')
if [ ! -n "${device_type}" ] ; then
die "ERROR: Cannot detect device type for device '${PUPPET_RESCUE_LABEL}', cannot continue!"
fi
echo "Copying data from device '${PUPPET_RESCUE_DRIVE}' (mounted into '${PUPPET_RESCUE_PATH}', type '${device_type}')"
mkdir -p "${PUPPET_RESCUE_PATH}" mkdir -p "${PUPPET_RESCUE_PATH}"
mount -t iso9660 -o ro "${PUPPET_RESCUE_DRIVE}" "${PUPPET_RESCUE_PATH}" mount -t "${device_type}" -o ro "${PUPPET_RESCUE_DRIVE}" "${PUPPET_RESCUE_PATH}"
mkdir -m 0700 -p "${TARGET}/etc/puppet/hieradata/" mkdir -m 0700 -p "${TARGET}/etc/puppet/hieradata/"
cp -a "${PUPPET_RESCUE_PATH}"/hieradata/* "${TARGET}/etc/puppet/hieradata/" cp -a "${PUPPET_RESCUE_PATH}"/hieradata/* "${TARGET}/etc/puppet/hieradata/"
umount -f "${PUPPET_RESCUE_PATH}" umount -f "${PUPPET_RESCUE_PATH}"
rmdir "${PUPPET_RESCUE_PATH}" rmdir "${PUPPET_RESCUE_PATH}"
;; ;;
/dev/null) none)
echo "Hiera rescue drive has been skipped as requested." echo "Hiera rescue drive has been skipped as requested."
;; ;;
*) *)
echo "ERROR: Unsupported rescue drive '${PUPPET_RESCUE_DRIVE}', cannot continue!" >&2 die "ERROR: Unsupported rescue drive '${PUPPET_RESCUE_DRIVE}', cannot continue!"
exit 1
;; ;;
esac esac
@ -2221,8 +2233,7 @@ puppet_install_from_git () {
check_puppet_rc "${PIPESTATUS[0]}" "2" check_puppet_rc "${PIPESTATUS[0]}" "2"
;; ;;
*) *)
echo "ERROR: Unsupported Debian release ${DEBIAN_RELEASE} detected, cannot continue!" >&2 die "ERROR: Unsupported Debian release ${DEBIAN_RELEASE} detected, cannot continue!"
exit 1
;; ;;
esac esac
} }
@ -2245,8 +2256,7 @@ puppet_install_from_puppet () {
check_puppet_rc "${PIPESTATUS[0]}" "2" check_puppet_rc "${PIPESTATUS[0]}" "2"
;; ;;
*) *)
echo "ERROR: Unsupported Debian release ${DEBIAN_RELEASE} detected, cannot continue!" >&2 die "ERROR: Unsupported Debian release ${DEBIAN_RELEASE} detected, cannot continue!"
exit 1
;; ;;
esac esac
} }

Loading…
Cancel
Save