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
This commit is contained in:
Michal Arbet 2024-02-08 15:25:12 +01:00
parent f17d3dfd97
commit 18899a7d52
4 changed files with 31 additions and 2 deletions

View File

@ -14,6 +14,7 @@
kolla_dev_repos_directory: "{{ kolla_dev_repos_directory }}" kolla_dev_repos_directory: "{{ kolla_dev_repos_directory }}"
opensearch_datadir_volume: "{{ opensearch_datadir_volume }}" opensearch_datadir_volume: "{{ opensearch_datadir_volume }}"
destroy_include_dev: "{{ destroy_include_dev }}" destroy_include_dev: "{{ destroy_include_dev }}"
kolla_ansible_inventories: "{{ inventories_comma_separated.replace(',',' ') }}"
- block: - block:
- name: Disable octavia-interface service - name: Disable octavia-interface service

View File

@ -0,0 +1,7 @@
---
fixes:
- |
Fixes kolla-ansible removing inventory file placed in
``/etc/kolla/<inventory>``.
See `LP#2052706 <https://launchpad.net/bugs/2052706>`__
for more details.

View File

@ -77,14 +77,27 @@ fi
echo "Getting folders name..." echo "Getting folders name..."
for dir in $FOLDER_PATH/*; do 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" ] || \ if [ "$dir" == "$FOLDER_PATH/passwords.yml" ] || \
[ "$dir" == "$FOLDER_PATH/globals.yml" ] || \ [ "$dir" == "$FOLDER_PATH/globals.yml" ] || \
[ "$dir" == "$FOLDER_PATH/globals.d" ] || \ [ "$dir" == "$FOLDER_PATH/globals.d" ] || \
[ "$dir" == "$FOLDER_PATH/kolla-build.conf" ] || \ [ "$dir" == "$FOLDER_PATH/kolla-build.conf" ] || \
[ "$dir" == "$FOLDER_PATH/config" ] || \ [ "$dir" == "$FOLDER_PATH/config" ] || \
[ "$dir" == "$FOLDER_PATH/certificates" ]; then [ "$dir" == "$FOLDER_PATH/certificates" ]; then
echo "Skipping:" $dir echo "Skipping: $dir"
else skip="true"
fi
# If it's not to be skipped, remove it
if [ "$skip" == "false" ]; then
rm -rfv $dir rm -rfv $dir
fi fi
done done

View File

@ -458,12 +458,20 @@ case "$1" in
(destroy) (destroy)
ACTION="Destroy Kolla containers, volumes and host configuration" ACTION="Destroy Kolla containers, volumes and host configuration"
PLAYBOOK="${BASEDIR}/ansible/destroy.yml" 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 if [[ "${INCLUDE_IMAGES}" == "--include-images" ]]; then
EXTRA_OPTS="$EXTRA_OPTS -e destroy_include_images=yes" EXTRA_OPTS="$EXTRA_OPTS -e destroy_include_images=yes"
fi fi
if [[ "${INCLUDE_DEV}" == "--include-dev" ]]; then if [[ "${INCLUDE_DEV}" == "--include-dev" ]]; then
EXTRA_OPTS="$EXTRA_OPTS -e destroy_include_dev=yes" EXTRA_OPTS="$EXTRA_OPTS -e destroy_include_dev=yes"
fi fi
EXTRA_OPTS="$EXTRA_OPTS -e inventories_comma_separated=${INVENTORIES_COMMA_SEPARATED}"
if [[ "${DANGER_CONFIRM}" != "--yes-i-really-really-mean-it" ]]; then if [[ "${DANGER_CONFIRM}" != "--yes-i-really-really-mean-it" ]]; then
cat << EOF cat << EOF
WARNING: WARNING: