From f95ad15a811c3111b42c09f569d0f1f303a8b597 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Fri, 6 Apr 2018 20:28:10 +0100 Subject: [PATCH] xci: Move sourcing of configuration files to the install-lib.sh The install-lib.sh assumes that certain configuration files have been loaded before it's sourced. However, this doesn't work well when other scripts are using install-lib.sh directly since they also need to load the same configuration files. As such, lets source all these configuration files from the install-lib.sh file directly. We also rename this file to 'xci-lib.sh' since it's not just about installation helpers anymore. Change-Id: I35e1e804db06b2bb512e4991e5fdf21a72ffaadb Signed-off-by: Markos Chandras --- xci/files/{install-lib.sh => xci-lib.sh} | 18 +++++++++++++++--- xci/xci-deploy.sh | 27 ++++++++------------------- 2 files changed, 23 insertions(+), 22 deletions(-) rename xci/files/{install-lib.sh => xci-lib.sh} (93%) diff --git a/xci/files/install-lib.sh b/xci/files/xci-lib.sh similarity index 93% rename from xci/files/install-lib.sh rename to xci/files/xci-lib.sh index af86be41..bdb64513 100644 --- a/xci/files/install-lib.sh +++ b/xci/files/xci-lib.sh @@ -7,9 +7,21 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -# NOTE(hwoarang): Most parts of this this file were taken from the -# bifrost repository (scripts/install-deps.sh). This script contains all -# the necessary distro specific code to install ansible and it's dependencies. +function bootstrap_xci_env() { + # Declare our virtualenv + export XCI_VENV=${XCI_PATH}/venv/ + + # source user vars + source $XCI_PATH/xci/config/user-vars + # source pinned versions + source $XCI_PATH/xci/config/pinned-versions + # source flavor configuration + source "$XCI_PATH/xci/config/${XCI_FLAVOR}-vars" + # source installer configuration + source "$XCI_PATH/xci/installer/${INSTALLER_TYPE}/env" &>/dev/null || true + # source xci configuration + source $XCI_PATH/xci/config/env-vars +} function install_ansible() { set -eu diff --git a/xci/xci-deploy.sh b/xci/xci-deploy.sh index a04fb21e..6f7490bd 100755 --- a/xci/xci-deploy.sh +++ b/xci/xci-deploy.sh @@ -81,20 +81,8 @@ fi #------------------------------------------------------------------------------- # find where are we export XCI_PATH="$(git rev-parse --show-toplevel)" -# Declare our virtualenv -export XCI_VENV=${XCI_PATH}/venv/ -# source user vars -source $XCI_PATH/xci/config/user-vars -# source pinned versions -source $XCI_PATH/xci/config/pinned-versions -# source flavor configuration -source "$XCI_PATH/xci/config/${XCI_FLAVOR}-vars" -# source installer configuration -source "$XCI_PATH/xci/installer/${INSTALLER_TYPE}/env" &>/dev/null || true -# source xci configuration -source $XCI_PATH/xci/config/env-vars # source helpers library -source ${XCI_PATH}/xci/files/install-lib.sh +source ${XCI_PATH}/xci/files/xci-lib.sh # Make sure we pass XCI_PATH everywhere export XCI_ANSIBLE_PARAMS+=" -e xci_path=${XCI_PATH}" @@ -114,17 +102,18 @@ for local_user_var in ${user_local_dev_vars[@]}; do done unset user_local_dev_vars local_user_var -# register our handler -trap exit_trap ERR - -# We are using sudo so we need to make sure that env_reset is not present -sudo sed -i "s/^Defaults.*env_reset/#&/" /etc/sudoers - # # Bootstrap environment for XCI Deployment # echo "Info: Preparing host environment for the XCI deployment" echo "-------------------------------------------------------------------------" +bootstrap_xci_env + +# register our handler +trap exit_trap ERR + +# We are using sudo so we need to make sure that env_reset is not present +sudo sed -i "s/^Defaults.*env_reset/#&/" /etc/sudoers #------------------------------------------------------------------------------- # Clean up environment -- 2.16.6