From 57cbc71938c05f5cf5799e3ef0596ae9551f54dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Magalh=C3=A3es?= Date: Fri, 4 Nov 2016 14:23:25 +0000 Subject: [PATCH] Add optional pip packages to horizon In some cases it's necessary to have additional pip packages when using custom dashboards. This change will allow to add new packages without the need of override the variable horizon_pip_packages using the new one horizon_optional_pip_packages. Change-Id: I3cf458c3c152bb85947bb9297637f64eb3d65232 --- defaults/main.yml | 4 ++++ tasks/horizon_install.yml | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index 17ef5acb..d1b59af3 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -256,6 +256,10 @@ horizon_pip_packages: - sahara_dashboard - trove_dashboard +# This variable is used to install additional pip packages +# that could be needed for additional dashboards +horizon_optional_pip_packages: [] + # This variable is used by the repo_build process to determine # which host group to check for members of before building the # pip packages required by this role. The value is picked up diff --git a/tasks/horizon_install.yml b/tasks/horizon_install.yml index 7d492ba9..7592c866 100644 --- a/tasks/horizon_install.yml +++ b/tasks/horizon_install.yml @@ -120,6 +120,22 @@ - horizon_get_venv | failed or horizon_developer_mode | bool notify: Restart apache2 +- name: Install optional pip packages + pip: + name: "{{ horizon_optional_pip_packages | join(' ') }}" + state: "{{ horizon_pip_package_state }}" + virtualenv: "{{ horizon_bin | dirname }}" + virtualenv_site_packages: "no" + extra_args: >- + {{ horizon_developer_mode | ternary('--constraint /opt/developer-pip-constraints.txt', '') }} + {{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }} + {{ pip_install_options | default('') }} + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + when: horizon_optional_pip_packages | length > 0 + - name: Update virtualenv path command: > virtualenv-tools --update-path=auto {{ horizon_bin | dirname }}