From dbc5967f7364489ba9a590969c3bba1a553b64fb Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Thu, 16 Feb 2017 13:42:21 +0000 Subject: [PATCH] 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 --- tools/kolla-ansible | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/kolla-ansible b/tools/kolla-ansible index e51240fbfb..251b3239ad 100755 --- a/tools/kolla-ansible +++ b/tools/kolla-ansible @@ -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