Avoids potential issues with changes not being fully written to disk
in teh result image.
Change-Id: I0dab01038870cbc798560863de1971a3a124983a
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
- ansible.builtin.command:
argv: ['cloud-init', 'clean']
ignore_errors: true
- ansible.builtin.command:
argv: ['cloud-init', 'clean']
ignore_errors: true
+ - ansible.built.command:
+ argv: ['sync']
- ansible.builtin.shell:
cmd: 'history -cw'
# Some default shells don't have the `history` built-in,
- ansible.builtin.shell:
cmd: 'history -cw'
# Some default shells don't have the `history` built-in,
TRIES_MAX=3
TRIES=0
while [[ "${TRIES}" -lt "${TRIES_MAX}" ]] ; do
TRIES_MAX=3
TRIES=0
while [[ "${TRIES}" -lt "${TRIES_MAX}" ]] ; do
- if ! INSTANCE_NAME=$(lxc -q launch -e "${VM_ARG[@]}" -p default -p "${LXD_INSTANCE_PROFILE}" "${SOURCE_IMAGE_NAME}/${IMAGE_TYPE}") ; then
+ if ! INSTANCE_NAME=$(lxc -q launch "${VM_ARG[@]}" -p default -p "${LXD_INSTANCE_PROFILE}" "${SOURCE_IMAGE_NAME}/${IMAGE_TYPE}") ; then
- if ! INSTANCE_NAME=$(lxc -q launch -e "${VM_ARG[@]}" -p default -p "${LXD_INSTANCE_PROFILE}" images:"${SOURCE_IMAGE_NAME}") ; then
+ if ! INSTANCE_NAME=$(lxc -q launch "${VM_ARG[@]}" -p default -p "${LXD_INSTANCE_PROFILE}" images:"${SOURCE_IMAGE_NAME}") ; then
TRIES=$((TRIES + 1))
echo "Failed to deployed ephemereal instance attempt ${TRIES}/${TRIES_MAX}"
if [[ "${TRIES}" -lt "${TRIES_MAX}" ]] ; then
TRIES=$((TRIES + 1))
echo "Failed to deployed ephemereal instance attempt ${TRIES}/${TRIES_MAX}"
if [[ "${TRIES}" -lt "${TRIES_MAX}" ]] ; then
- "lxc stop -f ${INSTANCE_NAME}"
+ "lxc delete -f ${INSTANCE_NAME}"
+ "lxc stop ${INSTANCE_NAME}"
)
# VMs may take more time to start, wait until instance is running
)
# VMs may take more time to start, wait until instance is running
playbooks/post-imagebuild-clean.yml \
-l "${INSTANCE_IP}" -i fake-inventory
playbooks/post-imagebuild-clean.yml \
-l "${INSTANCE_IP}" -i fake-inventory
+# Graceful shutdown
+lxc stop "${INSTANCE_NAME}"
+
-if FINGERPRINT=$(lxc publish "${INSTANCE_NAME}" -f 2>&1 | grep -E -o '[A-Fa-f0-9]{64}') ; then
+if FINGERPRINT=$(lxc publish "${INSTANCE_NAME}" 2>&1 | grep -E -o '[A-Fa-f0-9]{64}') ; then
echo "Published instance with fingerprint '${FINGERPRINT}'"
else
fail 1 "No fingerprint for published instance"
echo "Published instance with fingerprint '${FINGERPRINT}'"
else
fail 1 "No fingerprint for published instance"