Adds Search Path Override

If you follow the docs for developing validations, you will find
you run into an error when attempting to execute your new validation
because the code is currently hard coded to search in a path in
/usr/share where the packaging installs the validations.  For
development, you must hack the path in the script to make this work.

This patch adds a simple override where a developer can export
a path to the VALIDATIONS_BASEDIR environment variable and that will
be used as the search path for validations.  Example:

cd tripleo-validations
export VALIDATIONS_BASEDIR=$(pwd)

Depends-On: https://review.opendev.org/#/c/706196/
Change-Id: I064c11561af67d284dcf1ab024e0d600e12a8f98
(cherry picked from commit 20c791f815)
This commit is contained in:
Ryan Brady 2020-01-20 17:24:11 -05:00 committed by Gael Chamoulaud
parent c0fd6b0ebe
commit 1994eba458
2 changed files with 9 additions and 1 deletions

View File

@ -378,6 +378,14 @@ When running it, it should output something like this::
undercloud : ok=2 changed=0 unreachable=0 failed=0
If you run into an issue where the validation isn't found, it may be because the
run-validations.sh script is searching for it in the path where the packaging
installs validations. For development, export an environment variable named
VALIDATIONS_BASEDIR with the value of base bath of your git repo.::
cd /path/to/git/repo
export VALIDATIONS_BASEDIR=$(pwd)
Writing the full validation code is quite easy in this case because Ansible has
done all the hard work for us already. We can use the ``ansible_memtotal_mb``

View File

@ -69,7 +69,7 @@ if [ ${DEBUG:-no} == "yes" ]; then
ANSIBLE_DEBUG="-vvvv"
fi
VALIDATIONS_BASEDIR="/usr/share/openstack-tripleo-validations"
VALIDATIONS_BASEDIR=${VALIDATIONS_BASEDIR:="/usr/share/openstack-tripleo-validations"}
VAL=$(find $VALIDATIONS_BASEDIR/playbooks -type f -regex ".*playbooks\/${VALIDATION}\.y[a]?ml")
if [[ -z ${VAL} ]]; then