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
This commit is contained in:
Dmitriy Rabotyagov 2023-07-12 16:24:48 +02:00 committed by Dmitriy Rabotyagov
parent ea0bbd2c58
commit 6204256ff4

View File

@ -187,45 +187,47 @@ echo "openstack-ansible wrapper created."
[[ -d "/etc/ansible/plugins" ]] && rm -rf "/etc/ansible/plugins" [[ -d "/etc/ansible/plugins" ]] && rm -rf "/etc/ansible/plugins"
# Update dependent roles # 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
# NOTE(cloudnull): When bootstrapping we don't want ansible to interact # with our plugins by default. This change will force
# with our plugins by default. This change will force # ansible to ignore our plugins during this process.
# ansible to ignore our plugins during this process. export ANSIBLE_LIBRARY="${OSA_CLONE_DIR}/playbooks/library"
export ANSIBLE_LIBRARY="${OSA_CLONE_DIR}/playbooks/library" export ANSIBLE_LOOKUP_PLUGINS="/dev/null"
export ANSIBLE_LOOKUP_PLUGINS="/dev/null" export ANSIBLE_FILTER_PLUGINS="/dev/null"
export ANSIBLE_FILTER_PLUGINS="/dev/null" export ANSIBLE_ACTION_PLUGINS="/dev/null"
export ANSIBLE_ACTION_PLUGINS="/dev/null" export ANSIBLE_CALLBACK_PLUGINS="/dev/null"
export ANSIBLE_CALLBACK_PLUGINS="/dev/null" export ANSIBLE_CALLBACKS_ENABLED="/dev/null"
export ANSIBLE_CALLBACKS_ENABLED="/dev/null" export ANSIBLE_TEST_PLUGINS="/dev/null"
export ANSIBLE_TEST_PLUGINS="/dev/null" export ANSIBLE_VARS_PLUGINS="/dev/null"
export ANSIBLE_VARS_PLUGINS="/dev/null" export ANSIBLE_STRATEGY_PLUGINS="/dev/null"
export ANSIBLE_STRATEGY_PLUGINS="/dev/null" export ANSIBLE_CONFIG="none-ansible.cfg"
export ANSIBLE_CONFIG="none-ansible.cfg" export ANSIBLE_COLLECTIONS_PATH="/etc/ansible"
export ANSIBLE_COLLECTIONS_PATH="/etc/ansible" export ANSIBLE_TRANSPORT="smart"
export ANSIBLE_TRANSPORT="smart" export ANSIBLE_STRATEGY="linear"
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 \ /opt/ansible-runtime/bin/ansible-playbook get-ansible-collection-requirements.yml \
-e collection_file="${ANSIBLE_COLLECTION_FILE}" -e user_collection_file="${USER_COLLECTION_FILE}" -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 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." echo "System is bootstrapped and ready for use."