Only install to virtual environment

Remove all tasks and variables related to toggling between installation
of neutron 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: Ie0111886391d7ecdd50f1ac3a94f46a49f91f3fe
Implements: blueprint only-install-venvs
This commit is contained in:
Travis Truman 2016-07-07 11:04:10 -04:00
parent 7d65733e5a
commit e5a67a7c68
9 changed files with 28 additions and 147 deletions

View File

@ -40,25 +40,12 @@ neutron_developer_constraints:
# Name of the virtual env to deploy into # Name of the virtual env to deploy into
neutron_venv_tag: untagged neutron_venv_tag: untagged
neutron_venv_bin: "/openstack/venvs/neutron-{{ neutron_venv_tag }}/bin" neutron_bin: "/openstack/venvs/neutron-{{ neutron_venv_tag }}/bin"
# Set this to enable or disable installing in a venv
neutron_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.
neutron_bin: "{{ neutron_venv_bin }}"
neutron_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/neutron.tgz neutron_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/neutron.tgz
# Set the lib dir path to that of the local python path where neutron is installed. # Set the lib dir path to that of the local python path where neutron is installed.
# This is used for role access to the db migrations. neutron_lib_dir: "{{ neutron_bin | dirname }}/lib/python2.7/site-packages/"
# Example:
# neutron_lib_dir: "/usr/local/lib/python2.7/dist-packages/"
neutron_venv_lib_dir: "{{ neutron_bin | dirname }}/lib/python2.7/site-packages/"
neutron_non_venv_lib_dir: "/usr/local/lib/python2.7/dist-packages/"
neutron_lib_dir: "{{ (neutron_venv_enabled | bool) | ternary(neutron_venv_lib_dir, neutron_non_venv_lib_dir) }}"
# Enable/Disable Ceilometer # Enable/Disable Ceilometer
neutron_ceilometer_enabled: False neutron_ceilometer_enabled: False

View File

@ -0,0 +1,6 @@
---
upgrade:
- Installation of neutron and its dependent pip packages will now only
occur within a Python virtual environment. The ``neutron_venv_enabled``,
``neutron_venv_bin``, ``neutron_non_venv_lib_dir`` and
``neutron_venv_lib_dir`` variables have been removed.

View File

@ -83,7 +83,6 @@
get_md5: False get_md5: False
when: when:
- not neutron_developer_mode | bool - not neutron_developer_mode | bool
- neutron_venv_enabled | bool
register: local_venv_stat register: local_venv_stat
tags: tags:
- neutron-install - neutron-install
@ -95,7 +94,6 @@
return_content: True return_content: True
when: when:
- not neutron_developer_mode | bool - not neutron_developer_mode | bool
- neutron_venv_enabled | bool
register: remote_venv_checksum register: remote_venv_checksum
tags: tags:
- neutron-install - neutron-install
@ -115,7 +113,6 @@
register: get_venv register: get_venv
when: when:
- not neutron_developer_mode | bool - not neutron_developer_mode | bool
- neutron_venv_enabled | bool
- (local_venv_stat.stat.exists == False or - (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 }}) {{ local_venv_stat.stat.checksum is defined and local_venv_stat.stat.checksum != remote_venv_checksum.content | trim }})
tags: tags:
@ -125,17 +122,15 @@
- name: Set neutron get_venv fact - name: Set neutron get_venv fact
set_fact: set_fact:
neutron_get_venv: "{{ get_venv }}" neutron_get_venv: "{{ get_venv }}"
when: neutron_venv_enabled | bool
tags: tags:
- neutron-install - neutron-install
- neutron-pip-packages - neutron-pip-packages
- name: Remove existing venv - name: Remove existing venv
file: file:
path: "{{ neutron_venv_bin | dirname }}" path: "{{ neutron_bin | dirname }}"
state: absent state: absent
when: when:
- neutron_venv_enabled | bool
- neutron_get_venv | changed - neutron_get_venv | changed
tags: tags:
- neutron-install - neutron-install
@ -143,12 +138,11 @@
- name: Create neutron venv dir - name: Create neutron venv dir
file: file:
path: "{{ neutron_venv_bin | dirname }}" path: "{{ neutron_bin | dirname }}"
state: directory state: directory
register: neutron_venv_dir
when: when:
- not neutron_developer_mode | bool - not neutron_developer_mode | bool
- neutron_venv_enabled | bool
- neutron_get_venv | changed
tags: tags:
- neutron-install - neutron-install
- neutron-pip-packages - neutron-pip-packages
@ -156,33 +150,21 @@
- name: Unarchive pre-built venv - name: Unarchive pre-built venv
unarchive: unarchive:
src: "/var/cache/{{ neutron_venv_download_url | basename }}" src: "/var/cache/{{ neutron_venv_download_url | basename }}"
dest: "{{ neutron_venv_bin | dirname }}" dest: "{{ neutron_bin | dirname }}"
copy: "no" copy: "no"
when: when:
- not neutron_developer_mode | bool - not neutron_developer_mode | bool
- neutron_venv_enabled | bool - neutron_get_venv | changed or neutron_venv_dir | changed
- neutron_get_venv | changed
notify: Restart neutron services notify: Restart neutron services
tags: tags:
- neutron-install - neutron-install
- neutron-pip-packages - neutron-pip-packages
- name: Update virtualenv path - name: Install pip packages
command: >
virtualenv-tools --update-path=auto {{ neutron_venv_bin | dirname }}
when:
- not neutron_developer_mode | bool
- neutron_venv_enabled | bool
- neutron_get_venv | success
tags:
- neutron-install
- neutron-pip-packages
- name: Install pip packages (venv)
pip: pip:
name: "{{ item }}" name: "{{ item }}"
state: latest state: latest
virtualenv: "{{ neutron_venv_bin | dirname }}" virtualenv: "{{ neutron_bin | dirname }}"
virtualenv_site_packages: "no" virtualenv_site_packages: "no"
extra_args: "{{ pip_install_options_fact }}" extra_args: "{{ pip_install_options_fact }}"
register: install_packages register: install_packages
@ -191,27 +173,17 @@
delay: 2 delay: 2
with_items: "{{ neutron_pip_packages }}" with_items: "{{ neutron_pip_packages }}"
when: when:
- neutron_venv_enabled | bool
- neutron_get_venv | failed or neutron_developer_mode | bool - neutron_get_venv | failed or neutron_developer_mode | bool
notify: Restart neutron services notify: Restart neutron services
tags: tags:
- neutron-install - neutron-install
- neutron-pip-packages - neutron-pip-packages
- name: Install pip packages (no venv) - name: Update virtualenv path
pip: command: >
name: "{{ item }}" virtualenv-tools --update-path=auto {{ neutron_bin | dirname }}
state: latest
extra_args: "{{ pip_install_options_fact }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
with_items: "{{ neutron_pip_packages }}"
when: when:
- not neutron_developer_mode | bool - not neutron_developer_mode | bool
- not neutron_venv_enabled | bool
notify: Restart neutron services
tags: tags:
- neutron-install - neutron-install
- neutron-pip-packages - neutron-pip-packages

View File

@ -130,22 +130,6 @@
when: when:
- neutron_plugin_type == 'nuage' - neutron_plugin_type == 'nuage'
- name: Get neutron command path
command: which neutron
register: neutron_command_path
when:
- not neutron_venv_enabled | bool
tags:
- neutron-command-bin
- name: Set neutron command path
set_fact:
neutron_bin: "{{ neutron_command_path.stdout | dirname }}"
when:
- not neutron_venv_enabled | bool
tags:
- neutron-command-bin
- name: Drop sudoers file - name: Drop sudoers file
template: template:
src: "sudoers.j2" src: "sudoers.j2"

View File

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

View File

@ -12,33 +12,17 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
- name: Install nuage neutron pip packages (venv) - name: Install nuage neutron pip packages
pip: pip:
name: "{{ item }}" name: "{{ item }}"
state: latest state: latest
virtualenv: "{{ neutron_venv_bin | dirname }}" virtualenv: "{{ neutron_bin | dirname }}"
virtualenv_site_packages: "no" virtualenv_site_packages: "no"
retries: 5 retries: 5
delay: 2 delay: 2
with_items: with_items:
- "{{ neutron_proprietary_nuage_pip_packages }}" - "{{ neutron_proprietary_nuage_pip_packages }}"
when: when:
- neutron_venv_enabled | bool
- inventory_hostname in groups[neutron_services['neutron-server']['group']]
tags:
- neutron-install
- neutron-pip-packages
- name: Install nuage neutron pip packages (no venv)
pip:
name: "{{ item }}"
state: latest
retries: 5
delay: 2
with_items:
- "{{ neutron_proprietary_nuage_pip_packages }}"
when:
- not neutron_venv_enabled | bool
- inventory_hostname in groups[neutron_services['neutron-server']['group']] - inventory_hostname in groups[neutron_services['neutron-server']['group']]
tags: tags:
- neutron-install - neutron-install

View File

@ -32,11 +32,11 @@
tags: tags:
- neutron_config - neutron_config
- name: Install plumgrid pip packages (venv) - name: Install plumgrid pip packages
pip: pip:
name: "{{ item }}" name: "{{ item }}"
state: latest state: latest
virtualenv: "{{ neutron_venv_bin | dirname }}" virtualenv: "{{ neutron_bin | dirname }}"
virtualenv_site_packages: "no" virtualenv_site_packages: "no"
extra_args: "{{ pip_install_options|default('') }}" extra_args: "{{ pip_install_options|default('') }}"
register: install_packages register: install_packages
@ -47,17 +47,16 @@
with_items: with_items:
- "{{ neutron_optional_plumgrid_pip_packages }}" - "{{ neutron_optional_plumgrid_pip_packages }}"
when: when:
- neutron_venv_enabled | bool
- inventory_hostname in groups[neutron_services['neutron-server']['group']] - inventory_hostname in groups[neutron_services['neutron-server']['group']]
tags: tags:
- neutron-install - neutron-install
- neutron-pip-packages - neutron-pip-packages
- name: Install plumgrid pip packages fall back (venv) - name: Install plumgrid pip packages fall back
pip: pip:
name: "{{ item }}" name: "{{ item }}"
state: latest state: latest
virtualenv: "{{ neutron_venv_bin | dirname }}" virtualenv: "{{ neutron_bin | dirname }}"
virtualenv_site_packages: "no" virtualenv_site_packages: "no"
extra_args: "--isolated" extra_args: "--isolated"
register: install_packages_fall_back register: install_packages_fall_back
@ -68,45 +67,6 @@
- "{{ neutron_optional_plumgrid_pip_packages }}" - "{{ neutron_optional_plumgrid_pip_packages }}"
when: when:
- install_packages | failed - install_packages | failed
- neutron_venv_enabled | bool
- inventory_hostname in groups[neutron_services['neutron-server']['group']]
tags:
- neutron-install
- neutron-pip-packages
- name: Install plumgrid pip packages (no venv)
pip:
name: "{{ item }}"
state: latest
extra_args: "{{ pip_install_options|default('') }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
ignore_errors: True
with_items:
- "{{ neutron_optional_plumgrid_pip_packages }}"
when:
- not neutron_venv_enabled | bool
- inventory_hostname in groups[neutron_services['neutron-server']['group']]
tags:
- neutron-install
- neutron-pip-packages
- name: Install plumgrid pip packages fall back (no venv)
pip:
name: "{{ item }}"
state: latest
extra_args: "--isolated"
register: install_packages_fall_back
until: install_packages_fall_back|success
retries: 5
delay: 2
with_items:
- "{{ neutron_optional_plumgrid_pip_packages }}"
when:
- install_packages | failed
- not neutron_venv_enabled | bool
- inventory_hostname in groups[neutron_services['neutron-server']['group']] - inventory_hostname in groups[neutron_services['neutron-server']['group']]
tags: tags:
- neutron-install - neutron-install

View File

@ -1,4 +1,4 @@
#!{{ neutron_venv_enabled | bool | ternary(neutron_venv_bin + "/", "/usr/bin/env ") }}python #!{{ neutron_bin }}/python
# Copyright 2013 AT&T Services, Inc. # Copyright 2013 AT&T Services, Inc.
# All Rights Reserved. # All Rights Reserved.

View File

@ -23,9 +23,8 @@ pre-start script
mkdir -p "/var/lock/{{ program_name }}" mkdir -p "/var/lock/{{ program_name }}"
chown {{ system_user }}:{{ system_group }} "/var/lock/{{ program_name }}" chown {{ system_user }}:{{ system_group }} "/var/lock/{{ program_name }}"
{% if neutron_venv_enabled | bool -%} . {{ neutron_bin }}/activate
. {{ neutron_venv_bin }}/activate
{%- endif %}
end script end script