Support kolla-ansible installed in a virtualenv

Currently it is not possible to use kolla-ansible when it has been
installed in a virtualenv. Virtualenv-based installation may be
desirable when a suitable system package (e.g. RPM, .deb) is not
available, as it allows the user to install kolla-ansible and its
dependencies without affecting the system-wide packages.

This change checks for the presence of the $VIRTUAL_ENV environment
variable to determine whether we are running in an virtualenv. Since
kolla-ansible is not a python script, this comes with the caveat that we
must source the virtualenv activation script ($VIRTUAL_ENV/bin/activate)
before executing kolla-ansible.

Change-Id: I19efb96605bee3b16df3a0b78cd681e5f15499f6
Closes-Bug: #1530319
This commit is contained in:
Mark Goddard 2017-02-16 13:42:21 +00:00
parent 2825e18fc3
commit dbc5967f73
1 changed files with 2 additions and 0 deletions

View File

@ -10,6 +10,8 @@ function find_base_dir {
BASEDIR=/usr/share/kolla-ansible
elif [[ ${dir_name} == "/usr/local/bin" ]]; then
BASEDIR=/usr/local/share/kolla-ansible
elif [[ -n ${VIRTUAL_ENV} ]] && [[ ${dir_name} == "${VIRTUAL_ENV}/bin" ]]; then
BASEDIR="${VIRTUAL_ENV}/share/kolla-ansible"
else
BASEDIR="$(dirname ${dir_name})"
fi