From 6cefc8cf4ec6a77cd6066e8357e6d573014301b0 Mon Sep 17 00:00:00 2001 From: Artem Goncharov Date: Fri, 25 May 2018 19:17:32 +0200 Subject: [PATCH] allow passing ansible variables to ansible tests Provide possibility to pass ansible variables through environment (i.e. ANSIBLE_VAR_FLAVOR for setting `flavor` variable in ansible playbooks) to the ansible functional tests. This can be used i.e. for running tests in other than devstack cloud, where images, flavors, networks are not matching devstack. This is an initial change in a series of changes to enable executing ansible tests in other clouds as a validation. Change-Id: I40bc16241345ec4f39481f46dc0ad3a3075201fe --- extras/run-ansible-tests.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/extras/run-ansible-tests.sh b/extras/run-ansible-tests.sh index bda6007c9..c95c2395e 100755 --- a/extras/run-ansible-tests.sh +++ b/extras/run-ansible-tests.sh @@ -81,6 +81,15 @@ then tag_opt="--tags ${TAGS}" fi +# Loop through all ANSIBLE_VAR_ environment variables to allow passing the further +for var in $(env | grep -e '^ANSIBLE_VAR_'); do + VAR_NAME=${var%%=*} # split variable name from value + ANSIBLE_VAR_NAME=${VAR_NAME#ANSIBLE_VAR_} # cut ANSIBLE_VAR_ prefix from variable name + ANSIBLE_VAR_NAME=${ANSIBLE_VAR_NAME,,} # lowercase ansible variable + ANSIBLE_VAR_VALUE=${!VAR_NAME} # Get the variable value + ANSIBLE_VARS+="${ANSIBLE_VAR_NAME}=${ANSIBLE_VAR_VALUE} " # concat variables +done + # Until we have a module that lets us determine the image we want from # within a playbook, we have to find the image here and pass it in. # We use the openstack client instead of nova client since it can use clouds.yaml. @@ -91,4 +100,4 @@ then exit 1 fi -ansible-playbook -vvv ./openstack/tests/ansible/run.yml -e "cloud=${CLOUD} image=${IMAGE}" ${tag_opt} +ansible-playbook -vvv ./openstack/tests/ansible/run.yml -e "cloud=${CLOUD} image=${IMAGE} ${ANSIBLE_VARS}" ${tag_opt}