Trove-Rsync-Optional
Overview
Today, the guest rsyncs the code and trove-guestagent.conf via trove-guest.upstart.conf (or via trove-guest.systemd.conf if you're using fedora)
The proposal is to introduce an alternative that does not require guest-to-controller ssh connectivity: simply build the code and the conf in the image.
Proposed Implementation
scripts/files/elements/ubuntu-guest/extra-data.d/97-guest-code
#!/bin/bash set -e set -o xtrace # CONTEXT: HOST prior to IMAGE BUILD as SCRIPT USER # PURPOSE: Stages the guest agent artifacts to remove the need for the # initial rsync on boot source $_LIB/die [ -n "$TMP_HOOKS_PATH." ] || die "Temp hook path not set" if [ -n "${GUEST_LOCAL_TROVE_DIR}" ] && [ -n "${GUEST_LOCAL_TROVE_CONF}" ]; then if [ -e ${GUEST_LOCAL_TROVE_DIR} ]; then sudo cp -R ${GUEST_LOCAL_TROVE_DIR} ${TMP_HOOKS_PATH}/trove else die "GUEST_LOCAL_TROVE_DIR needs to be set to the local directory of the guest agent code" fi if [ -e ${GUEST_LOCAL_TROVE_CONF} ]; then sudo cp ${GUEST_LOCAL_TROVE_CONF} ${TMP_HOOKS_PATH}/trove-guestagent.conf else die "GUEST_LOCAL_TROVE_CONF needs to be set to the local path of trove-guestagent.conf" fi fi
scripts/files/elements/ubuntu-guest/install.d/97-guest-code
#!/bin/bash set -e set -o xtrace # CONTEXT: GUEST during CONSTRUCTION as ROOT # PURPOSE: Take staged guest agent artifacts (see extra-data.d/97-guest-code) # and place them appropriately TMP_HOOKS_DIR="/tmp/in_target.d" if [ -e "${TMP_HOOKS_DIR}/trove" ]; then sudo cp -R ${TMP_HOOKS_DIR}/trove "/home/${GUEST_USERNAME}/trove" sudo chown ${GUEST_USERNAME}:${GUEST_USERNAME} "/home/${GUEST_USERNAME}/trove" fi if [ -e "${TMP_HOOKS_DIR}/trove-guestagent.conf" ]; then sudo mkdir -p /etc/trove sudo cp ${TMP_HOOKS_DIR}/trove-guestagent.conf /etc/trove/trove-guestagent.conf sudo chown -R ${GUEST_USERNAME}:${GUEST_USERNAME} /etc/trove fi
scripts/functions_qemu
diff --git a/scripts/functions_qemu b/scripts/functions_qemu index c25a08f..5185168 100644 --- a/scripts/functions_qemu +++ b/scripts/functions_qemu @@ -39,6 +39,8 @@ function build_vm() { export ESCAPED_GUEST_LOGDIR export ELEMENTS_PATH=$REDSTACK_SCRIPTS/files/elements:$PATH_TRIPLEO_ELEMENTS/elements export DIB_CLOUD_INIT_DATASOURCES="ConfigDrive" + export GUEST_LOCAL_TROVE_DIR + export GUEST_LOCAL_TROVE_CONF ${PATH_DISKIMAGEBUILDER}/bin/disk-image-create -a amd64 -o "${VM}" -x ${DISTRO} ${EXTRA_ELEMENTS} vm heat-cfntools cloud-init-datasources ${DISTRO}-guest ${DISTRO}-${SERVICE_TYPE} }
scripts/redstack.rc
diff --git a/scripts/redstack.rc b/scripts/redstack.rc index 7cec701..d08eb29 100644 --- a/scripts/redstack.rc +++ b/scripts/redstack.rc @@ -49,3 +49,7 @@ SWIFT_DISK_IMAGE=${SWIFT_DATA_DIR}/drives/images/swift.img DISTRO=${DISTRO:-ubuntu} #DISTRO=fedora + +# Optionally install code and conf in image instead of using rsync +#GUEST_LOCAL_TROVE_DIR=$PATH_TROVE +#GUEST_LOCAL_TROVE_CONF=$TROVE_CONF_DIR/trove-guestagent.conf
Why?
- Testing: You can now easily build images with different versions of the guest and/or conf (to test compatibility against the control plane, or whatever)
- Altogether avoids general proxy/network issues when dealing with DevStack/RedStack (a different issue seems to crop up every release cycle)
- More secure; hints to deployers that they should not build images with the default rsync.