Only install to virtual environment

Remove all tasks and variables related to toggling between installation
of cinder 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: I21ebc977f3c6d97853150e8b42bcd35ab4c2ef09
Implements: blueprint only-install-venvs
This commit is contained in:
Travis Truman 2016-07-07 12:59:19 -04:00
parent 920a2695ac
commit df3b47973a
7 changed files with 17 additions and 77 deletions

View File

@ -24,15 +24,7 @@ cinder_developer_constraints:
# Name of the virtual env to deploy into
cinder_venv_tag: untagged
cinder_venv_bin: "/openstack/venvs/cinder-{{ cinder_venv_tag }}/bin"
# Set this to enable or disable installing in a venv
cinder_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.
cinder_bin: "{{ cinder_venv_bin }}"
cinder_bin: "/openstack/venvs/cinder-{{ cinder_venv_tag }}/bin"
cinder_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/cinder.tgz

View File

@ -0,0 +1,5 @@
---
upgrade:
- Installation of cinder and its dependent pip packages will now only
occur within a Python virtual environment. The ``cinder_venv_enabled``
and ``cinder_venv_bin`` variables have been removed.

View File

@ -84,7 +84,6 @@
get_md5: False
when:
- not cinder_developer_mode | bool
- cinder_venv_enabled | bool
register: local_venv_stat
tags:
- cinder-install
@ -96,7 +95,6 @@
return_content: True
when:
- not cinder_developer_mode | bool
- cinder_venv_enabled | bool
register: remote_venv_checksum
tags:
- cinder-install
@ -116,7 +114,6 @@
register: get_venv
when:
- not cinder_developer_mode | bool
- cinder_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:
@ -126,17 +123,15 @@
- name: Set cinder get_venv fact
set_fact:
cinder_get_venv: "{{ get_venv }}"
when: cinder_venv_enabled | bool
tags:
- cinder-install
- cinder-pip-packages
- name: Remove existing venv
file:
path: "{{ cinder_venv_bin | dirname }}"
path: "{{ cinder_bin | dirname }}"
state: absent
when:
- cinder_venv_enabled | bool
- cinder_get_venv | changed
tags:
- cinder-install
@ -144,11 +139,11 @@
- name: Create cinder venv dir
file:
path: "{{ cinder_venv_bin | dirname }}"
path: "{{ cinder_bin | dirname }}"
state: directory
register: cinder_venv_dir
when:
- not cinder_developer_mode | bool
- cinder_venv_enabled | bool
- cinder_get_venv | changed
tags:
- cinder-install
@ -157,33 +152,21 @@
- name: Unarchive pre-built venv
unarchive:
src: "/var/cache/{{ cinder_venv_download_url | basename }}"
dest: "{{ cinder_venv_bin | dirname }}"
dest: "{{ cinder_bin | dirname }}"
copy: "no"
when:
- not cinder_developer_mode | bool
- cinder_venv_enabled | bool
- cinder_get_venv | changed
- cinder_get_venv | changed or cinder_venv_dir | changed
notify: Restart cinder services
tags:
- cinder-install
- cinder-pip-packages
- name: Update virtualenv path
command: >
virtualenv-tools --update-path=auto {{ cinder_venv_bin | dirname }}
when:
- not cinder_developer_mode | bool
- cinder_venv_enabled | bool
- cinder_get_venv | success
tags:
- cinder-install
- cinder-pip-packages
- name: Install pip packages (venv)
- name: Install pip packages
pip:
name: "{{ item }}"
state: latest
virtualenv: "{{ cinder_venv_bin | dirname }}"
virtualenv: "{{ cinder_bin | dirname }}"
virtualenv_site_packages: "no"
extra_args: "{{ pip_install_options_fact }}"
register: install_packages
@ -192,27 +175,17 @@
delay: 2
with_items: "{{ cinder_pip_packages }}"
when:
- cinder_venv_enabled | bool
- cinder_get_venv | failed or cinder_developer_mode | bool
notify: Restart cinder services
tags:
- cinder-install
- cinder-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: "{{ cinder_pip_packages }}"
- name: Update virtualenv path
command: >
virtualenv-tools --update-path=auto {{ cinder_bin | dirname }}
when:
- not cinder_developer_mode | bool
- not cinder_venv_enabled | bool
notify: Restart cinder services
tags:
- cinder-install
- cinder-pip-packages

View File

@ -79,22 +79,6 @@
tags:
- cinder-nfs
- name: Get cinder command path
command: which cinder
register: cinder_command_path
when:
- not cinder_venv_enabled | bool
tags:
- cinder-command-bin
- name: Set cinder command path
set_fact:
cinder_bin: "{{ cinder_command_path.stdout | dirname }}"
when:
- not cinder_venv_enabled | bool
tags:
- cinder-command-bin
- name: Drop sudoers file
template:
src: "sudoers.j2"

View File

@ -49,17 +49,6 @@
tags:
- cinder-dirs
- name: Create cinder venv dir
file:
path: "{{ item.path }}"
state: directory
with_items:
- { path: "/openstack/venvs" }
- { path: "{{ cinder_venv_bin }}" }
when: cinder_venv_enabled | bool
tags:
- cinder-dirs
- name: Test for log directory or link
shell: |
if [ -h "/var/log/cinder" ]; 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 cinder_venv_enabled | bool -%}
. {{ cinder_venv_bin }}/activate
{%- endif %}
. {{ cinder_bin }}/activate
end script

View File

@ -16,7 +16,6 @@ cinder_galera_user: cinder
cinder_galera_database: cinder
cinder_requirements_git_install_branch: master
cinder_service_password: "secrete"
cinder_venv_bin: "/openstack/venvs/cinder-{{ cinder_venv_tag }}/bin"
cinder_venv_tag: "testing"
debug: true
external_lb_vip_address: 10.100.100.3