From 6204256ff4d13f95e8042c35ca3219485dcb41d0 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Wed, 12 Jul 2023 16:24:48 +0200 Subject: [PATCH] Allow to skip roles/collections bootstrap separately At the moment we control need of installing both roles and collections by `SKIP_OSA_ROLE_CLONE` environment variable. This patch introduces SKIP_OSA_COLLECTION_CLONE variable in addition to that, to enable operators more finely manage what needs bootstrapping. Change-Id: I07374bb52bebe27c94c229f1e759016cd34b286d --- scripts/bootstrap-ansible.sh | 74 ++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/scripts/bootstrap-ansible.sh b/scripts/bootstrap-ansible.sh index 83e929c2ad..ef11ed0664 100755 --- a/scripts/bootstrap-ansible.sh +++ b/scripts/bootstrap-ansible.sh @@ -187,45 +187,47 @@ echo "openstack-ansible wrapper created." [[ -d "/etc/ansible/plugins" ]] && rm -rf "/etc/ansible/plugins" # Update dependent roles -if [ -f "${ANSIBLE_ROLE_FILE}" ] && [[ -z "${SKIP_OSA_ROLE_CLONE+defined}" ]]; then - # NOTE(cloudnull): When bootstrapping we don't want ansible to interact - # with our plugins by default. This change will force - # ansible to ignore our plugins during this process. - export ANSIBLE_LIBRARY="${OSA_CLONE_DIR}/playbooks/library" - export ANSIBLE_LOOKUP_PLUGINS="/dev/null" - export ANSIBLE_FILTER_PLUGINS="/dev/null" - export ANSIBLE_ACTION_PLUGINS="/dev/null" - export ANSIBLE_CALLBACK_PLUGINS="/dev/null" - export ANSIBLE_CALLBACKS_ENABLED="/dev/null" - export ANSIBLE_TEST_PLUGINS="/dev/null" - export ANSIBLE_VARS_PLUGINS="/dev/null" - export ANSIBLE_STRATEGY_PLUGINS="/dev/null" - export ANSIBLE_CONFIG="none-ansible.cfg" - export ANSIBLE_COLLECTIONS_PATH="/etc/ansible" - export ANSIBLE_TRANSPORT="smart" - export ANSIBLE_STRATEGY="linear" +# NOTE(cloudnull): When bootstrapping we don't want ansible to interact +# with our plugins by default. This change will force +# ansible to ignore our plugins during this process. +export ANSIBLE_LIBRARY="${OSA_CLONE_DIR}/playbooks/library" +export ANSIBLE_LOOKUP_PLUGINS="/dev/null" +export ANSIBLE_FILTER_PLUGINS="/dev/null" +export ANSIBLE_ACTION_PLUGINS="/dev/null" +export ANSIBLE_CALLBACK_PLUGINS="/dev/null" +export ANSIBLE_CALLBACKS_ENABLED="/dev/null" +export ANSIBLE_TEST_PLUGINS="/dev/null" +export ANSIBLE_VARS_PLUGINS="/dev/null" +export ANSIBLE_STRATEGY_PLUGINS="/dev/null" +export ANSIBLE_CONFIG="none-ansible.cfg" +export ANSIBLE_COLLECTIONS_PATH="/etc/ansible" +export ANSIBLE_TRANSPORT="smart" +export ANSIBLE_STRATEGY="linear" - pushd scripts +pushd scripts +if ([ -f "${ANSIBLE_COLLECTION_FILE}" ] || [ -f "${USER_COLLECTION_FILE}" ]) && [[ -z "${SKIP_OSA_COLLECTION_CLONE+defined}" ]]; then /opt/ansible-runtime/bin/ansible-playbook get-ansible-collection-requirements.yml \ -e collection_file="${ANSIBLE_COLLECTION_FILE}" -e user_collection_file="${USER_COLLECTION_FILE}" - - /opt/ansible-runtime/bin/ansible-playbook get-ansible-role-requirements.yml \ - -e role_file="${ANSIBLE_ROLE_FILE}" -e user_role_file="${USER_ROLE_FILE}" - popd - - unset ANSIBLE_LIBRARY - unset ANSIBLE_LOOKUP_PLUGINS - unset ANSIBLE_FILTER_PLUGINS - unset ANSIBLE_ACTION_PLUGINS - unset ANSIBLE_CALLBACK_PLUGINS - unset ANSIBLE_CALLBACKS_ENABLED - unset ANSIBLE_TEST_PLUGINS - unset ANSIBLE_VARS_PLUGINS - unset ANSIBLE_STRATEGY_PLUGINS - unset ANSIBLE_CONFIG - unset ANSIBLE_COLLECTIONS_PATH - unset ANSIBLE_TRANSPORT - unset ANSIBLE_STRATEGY fi +if ([ -f "${ANSIBLE_ROLE_FILE}" ] || [ -f "${USER_ROLE_FILE}" ]) && [[ -z "${SKIP_OSA_ROLE_CLONE+defined}" ]]; then + /opt/ansible-runtime/bin/ansible-playbook get-ansible-role-requirements.yml \ + -e role_file="${ANSIBLE_ROLE_FILE}" -e user_role_file="${USER_ROLE_FILE}" +fi +popd + +unset ANSIBLE_LIBRARY +unset ANSIBLE_LOOKUP_PLUGINS +unset ANSIBLE_FILTER_PLUGINS +unset ANSIBLE_ACTION_PLUGINS +unset ANSIBLE_CALLBACK_PLUGINS +unset ANSIBLE_CALLBACKS_ENABLED +unset ANSIBLE_TEST_PLUGINS +unset ANSIBLE_VARS_PLUGINS +unset ANSIBLE_STRATEGY_PLUGINS +unset ANSIBLE_CONFIG +unset ANSIBLE_COLLECTIONS_PATH +unset ANSIBLE_TRANSPORT +unset ANSIBLE_STRATEGY + echo "System is bootstrapped and ready for use."