From 70f44bd55ffebde0d18741d92aac0a516bf5c7fa Mon Sep 17 00:00:00 2001 From: Logan V Date: Fri, 14 Sep 2018 11:13:44 -0600 Subject: [PATCH] Install ARA in-repo Until https://review.openstack.org/#/c/602461/ has merged, install ARA using scripts in this repo. This can be reverted once OSA supports externally triggering the ARA installation. Change-Id: I75e3ea94953315addf9a075889d26909127be7d3 --- .zuul.d/playbooks-deploy/run.yml | 1 + scripts/functions.sh | 29 +++++++++++++++++++++++++++++ scripts/run_deploy.sh | 6 ++++++ 3 files changed, 36 insertions(+) create mode 100644 scripts/functions.sh diff --git a/.zuul.d/playbooks-deploy/run.yml b/.zuul.d/playbooks-deploy/run.yml index 53d9432..dd39a74 100644 --- a/.zuul.d/playbooks-deploy/run.yml +++ b/.zuul.d/playbooks-deploy/run.yml @@ -6,6 +6,7 @@ environment: SSH_AUTH_SOCK: "{{ ssh_agent_sock }}" ANSIBLE_VAULT_PASSWORD_FILE: "{{ vault_key_path }}" + LSN_RUN_ARA: true tasks: - name: Run the deploy job command: scripts/run_deploy.sh diff --git a/scripts/functions.sh b/scripts/functions.sh new file mode 100644 index 0000000..e1f4b61 --- /dev/null +++ b/scripts/functions.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +LSN_RUN_ARA="${LSN_RUN_ARA:-false}" + +# The vars used to prepare the Ansible runtime venv +PIP_COMMAND="/opt/ansible-runtime/bin/pip" + +# NOTE(logan): Remove once https://review.openstack.org/#/c/602461/ +# has merged. +function setup_ara { + # Install ARA and add it to the callback path provided by bootstrap-ansible.sh/openstack-ansible.rc + # This is added *here* instead of bootstrap-ansible so it's used for CI purposes only. + ARA_SRC_HOME="${HOME}/src/git.openstack.org/openstack/ara" + if [[ -d "${ARA_SRC_HOME}" ]]; then + # This installs from a git checkout + # PIP_COMMAND and PIP_OPTS are exported by the bootstrap-ansible script. + # PIP_OPTS contains the whole set of constraints that need to be applied. + ${PIP_COMMAND} install --isolated ${PIP_OPTS} ${ARA_SRC_HOME} "${ANSIBLE_PACKAGE:-ansible}" + else + # This installs from pypi + # PIP_COMMAND and PIP_OPTS are exported by the bootstrap-ansible script. + # PIP_OPTS contains the whole set of constraints that need to be applied. + ${PIP_COMMAND} install --isolated ${PIP_OPTS} ara "${ANSIBLE_PACKAGE:-ansible}" + fi + # Dynamically retrieve the location of the ARA callback so we are able to find + # it on both py2 and py3 + ara_location=$(/opt/ansible-runtime/bin/python -c "import os,ara; print(os.path.dirname(ara.__file__))") + export ANSIBLE_CALLBACK_PLUGINS="/etc/ansible/roles/plugins/callback:${ara_location}/plugins/callbacks" +} diff --git a/scripts/run_deploy.sh b/scripts/run_deploy.sh index aa3284c..239d3b6 100755 --- a/scripts/run_deploy.sh +++ b/scripts/run_deploy.sh @@ -5,9 +5,15 @@ set -e export SCRIPT_PATH=$(dirname $(readlink -f "$0")) export PROJECT_PATH=$(dirname "$SCRIPT_PATH") +source "${SCRIPT_PATH}/functions.sh" + cp -R ${PROJECT_PATH}/openstack_deploy /etc pushd ${PROJECT_PATH}/openstack-ansible scripts/bootstrap-ansible.sh + +if [ "$LSN_RUN_ARA" == true ]; then + setup_ara +fi popd pushd ${PROJECT_PATH}/openstack-ansible/playbooks