diff --git a/test-ansible-deps.txt b/test-ansible-deps.txt index 280cd07b..fbd1f66b 100644 --- a/test-ansible-deps.txt +++ b/test-ansible-deps.txt @@ -13,6 +13,3 @@ git+git://github.com/ansible/ansible.git@e85f3f44610fa454c80da6b0f5ae84e3887a695 # The Ansible lint version used for lint tests ansible-lint==3.4.1 - -# ARA for reporting -ara diff --git a/test-ansible-env-prep.sh b/test-ansible-env-prep.sh index 598041b1..d583bb9e 100755 --- a/test-ansible-env-prep.sh +++ b/test-ansible-env-prep.sh @@ -95,15 +95,6 @@ else echo "Skipping the role link because no role name was provided." fi -# Link the ARA Callback directory to the the ansible callback directory -if [ -d "${WORKING_DIR}/.tox/functional/lib/python2.7/site-packages/ara/plugins/callbacks" ]; then - if [ ! -L "${ANSIBLE_PLUGIN_DIR}/callback/ara" ]; then - echo "Linking ${ANSIBLE_PLUGIN_DIR}/callback/ara to ${WORKING_DIR}/.tox/functional/lib/python2.7/site-packages/ara/plugins/callbacks/" - mkdir -p "${ANSIBLE_PLUGIN_DIR}/callback/ara" - ln -sf "${WORKING_DIR}/.tox/functional/lib/python2.7/site-packages/ara/plugins/callbacks" "${ANSIBLE_PLUGIN_DIR}/callback/ara/" - fi -fi - # Ensure that the Ansible configuration file is in the right place if [ ! -f "${ANSIBLE_CFG_PATH}" ]; then if [ -f "${COMMON_TESTS_PATH}/test-ansible.cfg" ]; then diff --git a/test-ansible-functional.sh b/test-ansible-functional.sh index 2c754089..61f8ce77 100755 --- a/test-ansible-functional.sh +++ b/test-ansible-functional.sh @@ -60,6 +60,29 @@ function set_ansible_parameters { } +function setup_ara { + + # Don't do anything if ARA has already been set up + [[ -L "${ANSIBLE_PLUGIN_DIR}/callback/ara" ]] && return 0 + + # Install ARA from source if running in ARA gate, otherwise install from PyPi + if [[ -e /usr/zuul-env/bin/zuul-cloner && "${ZUUL_PROJECT}" == "openstack/ara" ]]; then + /usr/zuul-env/bin/zuul-cloner --workspace /tmp --cache-dir /opt/git \ + git://git.openstack.org openstack/ara + ${WORKING_DIR}/.tox/functional/bin/pip install /tmp/openstack/ara + else + ${WORKING_DIR}/.tox/functional/bin/pip install ara + fi + + # Dynamically figure out the location of ARA (ex: py2 vs py3) + ara_location=$(${WORKING_DIR}/.tox/functional/bin/python -c "import os,ara; print(os.path.dirname(ara.__file__))") + + echo "Linking ${ANSIBLE_PLUGIN_DIR}/callback/ara to ${ara_location}/plugins/callbacks/" + mkdir -p "${ANSIBLE_PLUGIN_DIR}/callback/ara" + ln -sf "${ara_location}/plugins/callbacks" "${ANSIBLE_PLUGIN_DIR}/callback/ara/" + +} + function execute_ansible_playbook { CMD_TO_EXECUTE="ansible-playbook ${TEST_PLAYBOOK} $@ ${ANSIBLE_CLI_PARAMETERS}" @@ -80,6 +103,7 @@ function gate_job_exit_tasks { # Ensure that the Ansible environment is properly prepared source "${COMMON_TESTS_PATH}/test-ansible-env-prep.sh" +setup_ara # Set gate job exit traps, this is run regardless of exit state when the job finishes. trap gate_job_exit_tasks EXIT