From 5818696cf6e20860f94c2d54f2aa102a369c8a20 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Mon, 11 Jun 2018 23:21:17 -0500 Subject: [PATCH] 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 --- defaults/main.yml | 4 ++++ tasks/python_venv_install.yml | 2 +- tasks/python_venv_wheel_build.yml | 2 +- tests/test.yml | 2 ++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 923a7f5..ea99218 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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: [] diff --git a/tasks/python_venv_install.yml b/tasks/python_venv_install.yml index ce6a098..b2d48ad 100644 --- a/tasks/python_venv_install.yml +++ b/tasks/python_venv_install.yml @@ -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: >- diff --git a/tasks/python_venv_wheel_build.yml b/tasks/python_venv_wheel_build.yml index 48c10a2..e06c3d5 100644 --- a/tasks/python_venv_wheel_build.yml +++ b/tasks/python_venv_wheel_build.yml @@ -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 diff --git a/tests/test.yml b/tests/test.yml index e53ac96..b082443 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -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"