Only install to virtual environment

Remove all tasks and variables related to toggling between installation
of glance 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: Icfdfe3a6d47413875a49af3c38537fbd342bc16a
Implements: blueprint only-install-venvs
This commit is contained in:
Jimmy McCrory 2016-07-07 10:53:39 -07:00
parent 03a1def561
commit e03b37d610
6 changed files with 20 additions and 85 deletions

View File

@ -27,23 +27,13 @@ glance_developer_constraints:
# Name of the virtual env to deploy into
glance_venv_tag: untagged
glance_venv_bin: "/openstack/venvs/glance-{{ glance_venv_tag }}/bin"
# Set this to enable or disable installing in a venv
glance_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.
glance_bin: "{{ glance_venv_bin }}"
glance_bin: "/openstack/venvs/glance-{{ glance_venv_tag }}/bin"
# Set the etc dir path where glance is installed.
# This is used for role access to the db migrations.
# Example:
# glance_etc_dir: "/usr/local/etc/glance"
glance_venv_etc_dir: "{{ glance_bin | dirname }}/etc/glance"
glance_non_venv_etc_dir: "/usr/local/etc/glance"
glance_etc_dir: "{{ (glance_venv_enabled | bool) | ternary(glance_venv_etc_dir, glance_non_venv_etc_dir) }}"
glance_etc_dir: "{{ glance_bin | dirname }}/etc/glance"
glance_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/glance.tgz

View File

@ -0,0 +1,6 @@
---
upgrade:
- Installation of glance and its dependent pip packages will now only
occur within a Python virtual environment. The ``glance_venv_bin``,
``glance_venv_enabled``, ``glance_venv_etc_dir``, and
``glance_non_venv_etc_dir`` variables have been removed.

View File

@ -85,7 +85,6 @@
get_md5: False
when:
- not glance_developer_mode | bool
- glance_venv_enabled | bool
register: local_venv_stat
tags:
- glance-install
@ -97,7 +96,6 @@
return_content: True
when:
- not glance_developer_mode | bool
- glance_venv_enabled | bool
register: remote_venv_checksum
tags:
- glance-install
@ -117,7 +115,6 @@
register: get_venv
when:
- not glance_developer_mode | bool
- glance_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:
@ -127,17 +124,15 @@
- name: Set glance get_venv fact
set_fact:
glance_get_venv: "{{ get_venv }}"
when: glance_venv_enabled | bool
tags:
- glance-install
- glance-pip-packages
- name: Remove existing venv
file:
path: "{{ glance_venv_bin | dirname }}"
path: "{{ glance_bin | dirname }}"
state: absent
when:
- glance_venv_enabled | bool
- glance_get_venv | changed
tags:
- glance-install
@ -145,12 +140,9 @@
- name: Create glance venv dir
file:
path: "{{ glance_venv_bin | dirname }}"
path: "{{ glance_bin | dirname }}"
state: directory
when:
- not glance_developer_mode | bool
- glance_venv_enabled | bool
- glance_get_venv | changed
register: glance_venv_dir
tags:
- glance-install
- glance-pip-packages
@ -158,34 +150,22 @@
- name: Unarchive pre-built venv
unarchive:
src: "/var/cache/{{ glance_venv_download_url | basename }}"
dest: "{{ glance_venv_bin | dirname }}"
dest: "{{ glance_bin | dirname }}"
copy: "no"
when:
- not glance_developer_mode | bool
- glance_venv_enabled | bool
- glance_get_venv | changed
- glance_get_venv | changed or glance_venv_dir | changed
notify:
- Restart glance services
tags:
- glance-install
- glance-pip-packages
- name: Update virtualenv path
command: >
virtualenv-tools --update-path=auto {{ glance_venv_bin | dirname }}
when:
- not glance_developer_mode | bool
- glance_venv_enabled | bool
- glance_get_venv | success
tags:
- glance-install
- glance-pip-packages
- name: Install pip packages (venv)
- name: Install pip packages
pip:
name: "{{ item }}"
state: latest
virtualenv: "{{ glance_venv_bin | dirname }}"
virtualenv: "{{ glance_bin | dirname }}"
virtualenv_site_packages: "no"
extra_args: "{{ pip_install_options_fact }}"
register: install_packages
@ -194,7 +174,6 @@
delay: 2
with_items: "{{ glance_pip_packages }}"
when:
- glance_venv_enabled | bool
- glance_get_venv | failed or glance_developer_mode | bool
notify:
- Restart glance services
@ -202,21 +181,10 @@
- glance-install
- glance-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: "{{ glance_pip_packages }}"
when:
- not glance_venv_enabled | bool
- not glance_developer_mode | bool
notify:
- Restart glance services
- name: Update virtualenv path
command: >
virtualenv-tools --update-path=auto {{ glance_bin | dirname }}
tags:
- glance-install
- glance-pip-packages

View File

@ -94,22 +94,6 @@
- glance-nfs
- glance-nfs-local-path
- name: Get glance command path
command: which glance
register: glance_command_path
when:
- not glance_venv_enabled | bool
tags:
- glance-command-bin
- name: Set glance command path
set_fact:
glance_bin: "{{ glance_command_path.stdout | dirname }}"
when:
- not glance_venv_enabled | bool
tags:
- glance-command-bin
- name: Create glance cache management cron jobs
cron:
name: "{{ item.name }}"

View File

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

View File

@ -23,9 +23,7 @@ pre-start script
mkdir -p "/var/lock/{{ program_name }}"
chown {{ system_user }}:{{ system_group }} "/var/lock/{{ program_name }}"
{% if glance_venv_enabled | bool -%}
. {{ glance_venv_bin }}/activate
{%- endif %}
. {{ glance_bin }}/activate
end script