Fix some virtualenv-related places

- on Ubuntu Xenial, `python-virtualenv` package no longer installs
  `virtualenv` shell script.
  Change all `virtualenv` invocations to 'python -m virtualenv',
  which is more portable.
  - in `pip_install.yml`, add `virtualenv_command` argument using
    the same portable invocation.
- in `install-deps.sh`, the condition to install `python-virtualenv`
  was missing the `not` part
- the venv is created with `sudo` elevation in `install-deps.sh`,
  thus in `env-setup.sh` Ansible must be installed into venv
  using `sudo` elevation as well.
- in `install.yml`, fix passing `bifrost_venv_dir` var to `pip_install.yml`

Change-Id: Ifaa54a0dc97ed59ca8360e62878b603a04105e46
This commit is contained in:
Pavlo Shchelokovskyy 2017-03-14 07:55:40 +00:00
parent 83f39bb5a4
commit 390414b2a7
5 changed files with 13 additions and 7 deletions

View File

@ -80,10 +80,10 @@
source_install={{ ironicclient_source_install }}
when: skip_install is not defined
- name: "Install configparser in venv if using"
include: pip_install.yml package=configparser virtualenv=bifrost_venv_dir
include: pip_install.yml package=configparser virtualenv={{ bifrost_venv_dir }}
when: skip_install is not defined and (enable_venv | bool == true)
- name: "Install pymysql in venv if using"
include: pip_install.yml package=pymysql virtualenv=bifrost_venv_dir
include: pip_install.yml package=pymysql virtualenv={{ bifrost_venv_dir }}
when: skip_install is not defined and (enable_venv | bool == true)
- name: "Install Ironic using pip"
include: pip_install.yml

View File

@ -13,12 +13,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
---
- name: set virtualenv_command
set_fact:
venv_command: "{{ hostvars[inventory_hostname].ansible_python.executable }} -m virtualenv"
when: enable_venv
- name: "Install {{ package }} package from pip"
pip:
name: "{{ package }}"
state: "{{ state | default(omit) }}"
version: "{{ version | default(omit) }}"
virtualenv: "{{ bifrost_venv_dir if enable_venv else omit }}"
virtualenv_command: "{{ venv_command | default(omit) }}"
extra_args: "{{ extra_args | default(omit) }}"
when: source_install is not defined or source_install == false
# NOTE (cinerama): We should be able to use the pip module here and

View File

@ -10,7 +10,7 @@ ANSIBLE_PIP_VERSION=${ANSIBLE_PIP_VERSION:-${ANSIBLE_GIT_BRANCH:-stable-2.1}}
ANSIBLE_PIP_STRING=$(${PYTHON} $(dirname $0)/ansible-pip-str.py ${ANSIBLE_PIP_VERSION})
if [ -n "${VENV-}" ]; then
${PIP} install --upgrade "${ANSIBLE_PIP_STRING}"
sudo -H -E ${PIP} install --upgrade "${ANSIBLE_PIP_STRING}"
ANSIBLE=${VENV}/bin/ansible
else
${PIP} install --user --upgrade "${ANSIBLE_PIP_STRING}"

View File

@ -82,7 +82,7 @@ if ! $(wget --version &>/dev/null); then
${INSTALLER_CMD} ${PKG_MAP[wget]}
fi
if [ -n "${VENV-}" ]; then
if $(virtualenv --version &>/dev/null); then
if ! $(python -m virtualenv --version &>/dev/null); then
${INSTALLER_CMD} ${PKG_MAP[venv]}
fi
fi
@ -105,7 +105,7 @@ if [ -n "${VENV-}" ]; then
echo "NOTICE: Using virtualenv for this installation."
if [ ! -f ${VENV}/bin/activate ]; then
# only create venv if one doesn't exist
sudo -H -E virtualenv --no-site-packages ${VENV}
sudo -H -E python -m virtualenv --no-site-packages ${VENV}
fi
# Note(cinerama): activate is not compatible with "set -u";
# disable it just for this line.

View File

@ -94,12 +94,11 @@ fi
if [ ${USE_VENV} = "true" ]; then
export VENV=/opt/stack/bifrost
export PATH=${VENV}/bin:${PATH}
$SCRIPT_HOME/env-setup.sh
# Note(cinerama): activate is not compatible with "set -u";
# disable it just for this line.
set +u
source /opt/stack/bifrost/bin/activate
source ${VENV}/bin/activate
set -u
ANSIBLE=${VENV}/bin/ansible-playbook
ENABLE_VENV="true"