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
This commit is contained in:
parent
2d4be744a9
commit
6cefc8cf4e
|
@ -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}
|
||||
|
|
Loading…
Reference in New Issue