Only install to virtual environment

Remove all tasks and variables related to toggling between installation
of horizon inside or outside of a Python virtual environment.
Installing within a venv is now the only supported deployment.

Additionally, a few changes have been made to make the creation of the
venv more resistant to interruptions during a run of the role.
* unarchiving a pre-built venv will now also occur when the venv
  directory is created, not only after being downloaded
* virtualenv-tools is run against both pre-built and non pre-built venvs
  to account for interruptions during or prior to unarchiving

Change-Id: I8f5d33b90cc2c41beca2067f0f99d8c1283021e4
Implements: blueprint only-install-venvs
This commit is contained in:
Jimmy McCrory 2016-07-07 17:03:56 -07:00 committed by Anton Khaldin
parent 5617c4de57
commit 4559edf920
9 changed files with 31 additions and 96 deletions

View File

@ -26,15 +26,7 @@ horizon_developer_constraints:
# Name of the virtual env to deploy into
horizon_venv_tag: untagged
horizon_venv_bin: "/openstack/venvs/horizon-{{ horizon_venv_tag }}/bin"
# Set this to enable or disable installing in a venv
horizon_venv_enabled: true
# The bin path defaults to the venv path however if installation in a
# venv is disabled the bin path will be dynamically set based on the
# system path used when the installing.
horizon_bin: "{{ horizon_venv_bin }}"
horizon_bin: "/openstack/venvs/horizon-{{ horizon_venv_tag }}/bin"
horizon_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/horizon.tgz
@ -62,9 +54,7 @@ horizon_session_timeout: 1800
horizon_help_url: http://docs.openstack.org
## Installation directories
horizon_venv_lib_dir: "{{ horizon_bin | dirname }}/lib/python2.7/dist-packages"
horizon_non_venv_lib_dir: "/usr/local/lib/python2.7/dist-packages"
horizon_lib_dir: "{{ (horizon_venv_enabled | bool) | ternary(horizon_venv_lib_dir, horizon_non_venv_lib_dir) }}"
horizon_lib_dir: "{{ horizon_bin | dirname }}/lib/python2.7/dist-packages"
horizon_lib_wsgi_file: "{{ horizon_lib_dir }}/openstack_dashboard/wsgi/django.wsgi"
horizon_endpoint_type: internalURL

View File

@ -0,0 +1,6 @@
---
upgrade:
- Installation of horizon and its dependent pip packages will now only
occur within a Python virtual environment. The ``horizon_venv_bin``,
``horizon_venv_enabled``, ``horizon_venv_lib_dir``, and
``horizon_non_venv_lib_dir`` variables have been removed.

View File

@ -82,7 +82,6 @@
get_md5: False
when:
- not horizon_developer_mode | bool
- horizon_venv_enabled | bool
register: local_venv_stat
tags:
- horizon-install
@ -94,7 +93,6 @@
return_content: True
when:
- not horizon_developer_mode | bool
- horizon_venv_enabled | bool
register: remote_venv_checksum
tags:
- horizon-install
@ -114,7 +112,6 @@
register: get_venv
when:
- not horizon_developer_mode | bool
- horizon_venv_enabled | bool
- (local_venv_stat.stat.exists == False or
{{ local_venv_stat.stat.checksum is defined and local_venv_stat.stat.checksum != remote_venv_checksum.content | trim }})
tags:
@ -124,17 +121,15 @@
- name: Set horizon get_venv fact
set_fact:
horizon_get_venv: "{{ get_venv }}"
when: horizon_venv_enabled | bool
tags:
- horizon-install
- horizon-pip-packages
- name: Remove existing venv
file:
path: "{{ horizon_venv_bin | dirname }}"
path: "{{ horizon_bin | dirname }}"
state: absent
when:
- horizon_venv_enabled | bool
- horizon_get_venv | changed
tags:
- horizon-install
@ -142,11 +137,11 @@
- name: Create horizon venv dir
file:
path: "{{ horizon_venv_bin | dirname }}"
path: "{{ horizon_bin | dirname }}"
state: directory
register: horizon_venv_dir
when:
- not horizon_developer_mode | bool
- horizon_venv_enabled | bool
- horizon_get_venv | changed
tags:
- horizon-install
@ -155,33 +150,21 @@
- name: Unarchive pre-built venv
unarchive:
src: "/var/cache/{{ horizon_venv_download_url | basename }}"
dest: "{{ horizon_venv_bin | dirname }}"
dest: "{{ horizon_bin | dirname }}"
copy: "no"
when:
- not horizon_developer_mode | bool
- horizon_venv_enabled | bool
- horizon_get_venv | changed
- horizon_get_venv | changed or horizon_venv_dir | changed
notify: Restart apache2
tags:
- horizon-install
- horizon-pip-packages
- name: Update virtualenv path
command: >
virtualenv-tools --update-path=auto {{ horizon_venv_bin | dirname }}
when:
- not horizon_developer_mode | bool
- horizon_venv_enabled | bool
- horizon_get_venv | success
tags:
- horizon-install
- horizon-pip-packages
- name: Install pip packages (venv)
- name: Install pip packages
pip:
name: "{{ item }}"
state: latest
virtualenv: "{{ horizon_venv_bin | dirname }}"
virtualenv: "{{ horizon_bin | dirname }}"
virtualenv_site_packages: "no"
extra_args: "{{ pip_install_options_fact }}"
register: install_packages
@ -190,41 +173,28 @@
delay: 2
with_items: "{{ horizon_pip_packages }}"
when:
- horizon_venv_enabled | bool
- horizon_get_venv | failed or horizon_developer_mode | bool
notify: Restart apache2
tags:
- horizon-pip-packages
- name: Install pip packages (no venv)
pip:
name: "{{ item }}"
state: latest
extra_args: "{{ pip_install_options_fact }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
with_items: "{{ horizon_pip_packages }}"
- name: Update virtualenv path
command: >
virtualenv-tools --update-path=auto {{ horizon_bin | dirname }}
when:
- not horizon_developer_mode | bool
- not horizon_venv_enabled | bool
notify: Restart apache2
- horizon_get_venv | success
tags:
- horizon-install
- horizon-pip-packages
- name: Create horizon links for venv
- name: Create horizon link for venv
file:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
src: "{{ horizon_lib_dir | dirname }}/site-packages"
dest: "{{ horizon_lib_dir }}"
owner: "{{ horizon_system_user_name }}"
group: "{{ horizon_system_group_name }}"
state: "link"
with_items:
- src: "{{ horizon_lib_dir | dirname }}/site-packages"
dest: "{{ horizon_lib_dir }}"
when:
- horizon_venv_enabled | bool
tags:
- horizon-install
- horizon-configs

View File

@ -13,25 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Because there is no specific "horizon" command this method
# is looking for the "keystone" command to set the horizon
# command path.
- name: Get horizon command path
command: which keystone
register: horizon_command_path
when:
- not horizon_venv_enabled | bool
tags:
- horizon-command-bin
- name: Set horizon command path
set_fact:
horizon_bin: "{{ horizon_command_path.stdout | dirname }}"
when:
- not horizon_venv_enabled | bool
tags:
- horizon-command-bin
- name: Setup Horizon config(s)
template:
src: "{{ item.src }}"
@ -58,8 +39,8 @@
- name: Enable the neutron-lbaas-dashboard Horizon panel
file:
src: "{{ horizon_venv_lib_dir }}/neutron_lbaas_dashboard/enabled/_1481_project_ng_loadbalancersv2_panel.py"
path: "{{ horizon_venv_lib_dir }}/openstack_dashboard/local/enabled/_1481_project_ng_loadbalancersv2_panel.py"
src: "{{ horizon_lib_dir }}/neutron_lbaas_dashboard/enabled/_1481_project_ng_loadbalancersv2_panel.py"
path: "{{ horizon_lib_dir }}/openstack_dashboard/local/enabled/_1481_project_ng_loadbalancersv2_panel.py"
state: "{{ (horizon_enable_neutron_lbaas | bool) | ternary('link', 'absent') }}"
notify: Restart apache2
tags:

View File

@ -46,18 +46,6 @@
tags:
- horizon-dirs
- name: Create horizon venv dir
file:
path: "{{ item.path }}"
state: directory
with_items:
- { path: "/openstack/venvs" }
- { path: "{{ horizon_venv_bin }}" }
when:
- horizon_venv_enabled | bool
tags:
- horizon-dirs
- name: Test for log directory or link
shell: |
if [ -h "/var/log/horizon" ]; then

View File

@ -1,4 +1,4 @@
#!{{ horizon_venv_enabled | bool | ternary(horizon_venv_bin + "/", "/usr/bin/env ") }}python
#!{{ horizon_bin }}/python
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain

View File

@ -36,7 +36,7 @@
{% endif %}
WSGIScriptAlias / {{ horizon_lib_wsgi_file }}
WSGIDaemonProcess horizon user={{ horizon_system_user_name }} group={{ horizon_system_group_name }} processes={{ horizon_wsgi_processes | default(wsgi_threads) }} threads={{ horizon_wsgi_threads | default(wsgi_threads) }} {% if horizon_venv_enabled | bool %}python-path={{ horizon_venv_bin | dirname }}/lib/python2.7/site-packages{% endif %}
WSGIDaemonProcess horizon user={{ horizon_system_user_name }} group={{ horizon_system_group_name }} processes={{ horizon_wsgi_processes | default(wsgi_threads) }} threads={{ horizon_wsgi_threads | default(wsgi_threads) }} python-path={{ horizon_bin | dirname }}/lib/python2.7/site-packages
WSGIProcessGroup horizon
WSGIApplicationGroup horizon

View File

@ -20,8 +20,8 @@
tasks:
- name: Run tempest
shell: |
. {{ tempest_venv_bin }}/activate
{{ tempest_venv_bin | dirname }}/run_tempest.sh --no-virtual-env ${RUN_TEMPEST_OPTS} tempest_horizon.tests.scenario.test_dashboard_basic_ops.TestDashboardBasicOps
. {{ tempest_bin }}/activate
{{ tempest_bin | dirname }}/run_tempest.sh --no-virtual-env ${RUN_TEMPEST_OPTS} tempest_horizon.tests.scenario.test_dashboard_basic_ops.TestDashboardBasicOps
environment:
RUN_TEMPEST_OPTS: "--serial"
vars_files:

View File

@ -66,9 +66,9 @@ tempest_dashboard_url: "https://10.100.100.4/"
tempest_developer_mode: True
tempest_git_install_branch: master
tempest_venv_tag: "{{ tempest_git_install_branch }}"
# tempest_venv_bin is the same as the default in os_tempest role, but we set
# tempest_bin is the same as the default in os_tempest role, but we set
# it again here so we can refer to it in test-horizon-functional.yml
tempest_venv_bin: "/opt/tempest_{{ tempest_venv_tag }}/bin"
tempest_bin: "/opt/tempest_{{ tempest_venv_tag }}/bin"
tempest_log_dir: "/var/log/"
tempest_main_group: horizon_all
tempest_service_available_aodh: False