From 18899a7d525bc4b4d2e547e78d4b7aa9ec9645a0 Mon Sep 17 00:00:00 2001 From: Michal Arbet Date: Thu, 8 Feb 2024 15:25:12 +0100 Subject: Do not remove inventory file if placed in /etc/kolla This patch fix issue when inventory file is deleted by kolla-ansible -i /etc/kolla/inventory destroy call. Now, inventories are available in tools/cleanup-host so we can ignore their removal. Closes-Bug: #2052706 Change-Id: If89e94356de515b40ca4e8c023979cd498146303 --- tools/cleanup-host | 17 +++++++++++++++-- tools/kolla-ansible | 8 ++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/cleanup-host b/tools/cleanup-host index b0dfb4782..fc6e94320 100755 --- a/tools/cleanup-host +++ b/tools/cleanup-host @@ -77,14 +77,27 @@ fi echo "Getting folders name..." for dir in $FOLDER_PATH/*; do + skip="false" + + for inventory in $kolla_ansible_inventories; do + if [ "$dir" == "$inventory" ]; then + skip="true" + break + fi + done + if [ "$dir" == "$FOLDER_PATH/passwords.yml" ] || \ [ "$dir" == "$FOLDER_PATH/globals.yml" ] || \ [ "$dir" == "$FOLDER_PATH/globals.d" ] || \ [ "$dir" == "$FOLDER_PATH/kolla-build.conf" ] || \ [ "$dir" == "$FOLDER_PATH/config" ] || \ [ "$dir" == "$FOLDER_PATH/certificates" ]; then - echo "Skipping:" $dir - else + echo "Skipping: $dir" + skip="true" + fi + + # If it's not to be skipped, remove it + if [ "$skip" == "false" ]; then rm -rfv $dir fi done diff --git a/tools/kolla-ansible b/tools/kolla-ansible index 976853cf5..f7c7ee17d 100755 --- a/tools/kolla-ansible +++ b/tools/kolla-ansible @@ -458,12 +458,20 @@ case "$1" in (destroy) ACTION="Destroy Kolla containers, volumes and host configuration" PLAYBOOK="${BASEDIR}/ansible/destroy.yml" + + INVENTORIES_COMMA_SEPARATED="" + for INVENTORY in ${INVENTORIES[@]}; do + INVENTORIES_COMMA_SEPARATED="${INVENTORIES_COMMA_SEPARATED},${INVENTORY}" + done + INVENTORIES_COMMA_SEPARATED=$(echo "${INVENTORIES_COMMA_SEPARATED}" | sed -e 's/^,//g') + if [[ "${INCLUDE_IMAGES}" == "--include-images" ]]; then EXTRA_OPTS="$EXTRA_OPTS -e destroy_include_images=yes" fi if [[ "${INCLUDE_DEV}" == "--include-dev" ]]; then EXTRA_OPTS="$EXTRA_OPTS -e destroy_include_dev=yes" fi + EXTRA_OPTS="$EXTRA_OPTS -e inventories_comma_separated=${INVENTORIES_COMMA_SEPARATED}" if [[ "${DANGER_CONFIRM}" != "--yes-i-really-really-mean-it" ]]; then cat << EOF WARNING: -- cgit v1.2.3