From e315e2e32738aed2b0a59ef8099280dee698607b Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Mon, 28 Nov 2022 16:38:54 +0100 Subject: [PATCH] Allow to define user.rc file for OSA At the moment there is no handy functionality to override ENV variables and store them in git near OSA config. As while we take into account that ENV vars can already exist and we should use them, these VARs must be defined in /etc/environement or bashrc files. This patch aims to look for user.rc file inside OSA_CONFIG_DIR. If it's present - it will be sourced with all it's content. This way deployers can store environemnt variables overrides in git and they will be loaded during on openstack-ansible startup. Change-Id: Ie24ada54a0e0dc064be028929b416d983fdb5b49 --- releasenotes/notes/user_rc-9d530bd4b31cebaa.yaml | 7 +++++++ scripts/openstack-ansible.sh | 6 ++++++ 2 files changed, 13 insertions(+) create mode 100644 releasenotes/notes/user_rc-9d530bd4b31cebaa.yaml diff --git a/releasenotes/notes/user_rc-9d530bd4b31cebaa.yaml b/releasenotes/notes/user_rc-9d530bd4b31cebaa.yaml new file mode 100644 index 0000000000..9f8e6ea6c9 --- /dev/null +++ b/releasenotes/notes/user_rc-9d530bd4b31cebaa.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Added possibility to source environment variables from a user file that + will have prescedence over all environemnt variables loaded after + openstack-ansible.rc and have prescedence over all variables defined there + By default path to the user file is ``/etc/openstack_deploy/user.rc``. diff --git a/scripts/openstack-ansible.sh b/scripts/openstack-ansible.sh index ede218d30a..7d6fa2e2fb 100644 --- a/scripts/openstack-ansible.sh +++ b/scripts/openstack-ansible.sh @@ -55,6 +55,12 @@ if [[ "${PWD}" == *"${OSA_CLONE_ROOT}"* ]] || [ "${RUN_CMD}" == "openstack-ansib fi fi + OSA_USER_RC="${OSA_USER_RC:-${OSA_CONFIG_DIR}/user.rc}" + + if [[ -f ${OSA_USER_RC} ]]; then + source ${OSA_USER_RC} + fi + # Check whether there are any user configuration files if ls -1 ${OSA_CONFIG_DIR}/user_*.yml &> /dev/null; then