Add option for default pip package install

Add an option to define a default set of python packages to install
within a virtual environment. This can be used to install a package
wihin a virtual environment that may be outside of a normal package
list but for a given service.

Change-Id: Ic2dc024049062ad9be396a1f71435f661576e91b
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2018-06-11 23:21:17 -05:00 committed by Jesse Pretorius
parent 381f3ffba2
commit 5818696cf6
4 changed files with 8 additions and 2 deletions

View File

@ -43,6 +43,10 @@ venv_pip_package_state: "latest"
# package manager.
venv_distro_cache_valid_time: 600
# Default python packages which will be installed
# into every venv.
venv_default_pip_packages: []
# Python packages which must be installed
# into the venv.
venv_pip_packages: []

View File

@ -70,7 +70,7 @@
- name: Install python packages into the venv
pip:
name: "{{ venv_pip_packages }}"
name: "{{ venv_default_pip_packages + venv_pip_packages }}"
state: "{{ venv_pip_package_state }}"
virtualenv: "{{ venv_install_destination_path }}"
extra_args: >-

View File

@ -82,7 +82,7 @@
--find-links {{ venv_build_host_wheel_path }}/
--log /var/log/python_wheel_build.log
{{ venv_pip_install_args }}
{{ venv_pip_packages | join(' ') }}
{{ (venv_default_pip_packages + venv_pip_packages) | join(' ') }}
register: _build_python_wheels
until: _build_python_wheels is success
retries: 5

View File

@ -138,6 +138,8 @@
remote_user: root
any_errors_fatal: yes
vars:
venv_default_pip_packages:
- "elasticsearch>=6.0.0,<7.0.0"
venv_pip_packages:
- "Jinja2==2.10"
venv_install_destination_path: "/openstack/venvs/test-venv"