Only install to virtual environment

Remove all tasks and variables related to toggling between installation
of nova 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: Ia8687d49803705702f0e9f7ea9a83d3c05694d46
Implements: blueprint only-install-venvs
This commit is contained in:
Anton Khaldin 2016-07-13 08:17:40 -07:00 committed by Jimmy McCrory
parent e732f40b2c
commit 7f69cdd1df
10 changed files with 31 additions and 174 deletions

View File

@ -29,15 +29,7 @@ nova_developer_constraints:
# Name of the virtual env to deploy into # Name of the virtual env to deploy into
nova_venv_tag: untagged nova_venv_tag: untagged
nova_venv_bin: "/openstack/venvs/nova-{{ nova_venv_tag }}/bin" nova_bin: "/openstack/venvs/nova-{{ nova_venv_tag }}/bin"
# Set this to enable or disable installing in a venv
nova_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.
nova_bin: "{{ nova_venv_bin }}"
nova_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/nova.tgz nova_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/nova.tgz

View File

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

View File

@ -36,11 +36,11 @@
- qemu_savedir_stat.stat.isdir - qemu_savedir_stat.stat.isdir
- qemu_savedir_empty.stdout_lines | length == 0 - qemu_savedir_empty.stdout_lines | length == 0
- name: Install pip packages (venv) - name: Install pip packages
pip: pip:
name: "{{ item }}" name: "{{ item }}"
state: latest state: latest
virtualenv: "{{ nova_venv_bin | dirname }}" virtualenv: "{{ nova_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
@ -49,7 +49,6 @@
delay: 2 delay: 2
with_items: "{{ nova_compute_pip_packages }}" with_items: "{{ nova_compute_pip_packages }}"
when: when:
- nova_venv_enabled | bool
- nova_get_venv | failed or nova_developer_mode | bool - nova_get_venv | failed or nova_developer_mode | bool
tags: tags:
- nova-install - nova-install
@ -60,31 +59,16 @@
# There is a change in the works to upload the guestfs package to pypi in the # There is a change in the works to upload the guestfs package to pypi in the
# future however that's not been done as of yet. # future however that's not been done as of yet.
# related thread http://lists.openstack.org/pipermail/openstack-dev/2015-July/070927.html # related thread http://lists.openstack.org/pipermail/openstack-dev/2015-July/070927.html
# link on bug about libguestfs on pypi https://bugzilla.redhat.com/show_bug.cgi?id=1075594
- name: Link guestfs into the venv - name: Link guestfs into the venv
file: file:
src: "{{ item.name }}" src: "{{ item.name }}"
dest: "{{ nova_venv_bin | dirname }}/lib/python2.7/{{ item.name | basename }}" dest: "{{ nova_bin | dirname }}/lib/python2.7/{{ item.name | basename }}"
state: "{{ item.state }}" state: "{{ item.state }}"
force: "yes" force: "yes"
with_items: with_items:
- { state: link, name: "/usr/lib/python2.7/dist-packages/libguestfsmod.so" } - { state: link, name: "/usr/lib/python2.7/dist-packages/libguestfsmod.so" }
- { state: link, name: "/usr/lib/python2.7/dist-packages/guestfs.py" } - { state: link, name: "/usr/lib/python2.7/dist-packages/guestfs.py" }
when: nova_venv_enabled | bool
tags:
- nova-install
- nova-pip-packages
- name: Install 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
with_items: "{{ nova_compute_pip_packages }}"
when: not nova_venv_enabled | bool
tags: tags:
- nova-install - nova-install
- nova-pip-packages - nova-pip-packages

View File

@ -74,27 +74,23 @@
- name: Register pypowervm module path (venv) - name: Register pypowervm module path (venv)
command: python -c 'import pypowervm; print pypowervm.__file__' command: python -c 'import pypowervm; print pypowervm.__file__'
register: pypowervm_module_path register: pypowervm_module_path
when:
- nova_venv_enabled | bool
tags: tags:
- nova-powervm-libs - nova-powervm-libs
- name: Link pypowervm module into the venv - name: Link pypowervm module into the venv
file: file:
src: "{{ pypowervm_module_path.stdout | dirname }}" src: "{{ pypowervm_module_path.stdout | dirname }}"
dest: "{{ nova_venv_bin | dirname }}/lib/python2.7/site-packages/pypowervm" dest: "{{ nova_bin | dirname }}/lib/python2.7/site-packages/pypowervm"
state: link state: link
force: "yes" force: "yes"
when:
- nova_venv_enabled | bool
tags: tags:
- nova-powervm-libs - nova-powervm-libs
- name: Install pip packages (venv) - name: Install pip packages
pip: pip:
name: "{{ item }}" name: "{{ item }}"
state: latest state: latest
virtualenv: "{{ nova_venv_bin | dirname }}" virtualenv: "{{ nova_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
@ -102,61 +98,15 @@
retries: 5 retries: 5
delay: 2 delay: 2
with_items: "{{ nova_compute_powervm_pip_packages }}" with_items: "{{ nova_compute_powervm_pip_packages }}"
when:
- nova_venv_enabled | bool
tags: tags:
- nova-install - nova-install
- nova-pip-packages - nova-pip-packages
- name: Install pip packages (no venv) - name: Link nova_powervm module into the nova virt
pip:
name: "{{ item }}"
state: latest
extra_args: "{{ pip_install_options|default('') }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
with_items: "{{ nova_compute_powervm_pip_packages }}"
when: not nova_venv_enabled | bool
tags:
- nova-install
- nova-pip-packages
- name: Register nova module path (no venv)
command: python -c 'import nova; print nova.__file__'
register: nova_module_path
when:
- not nova_venv_enabled | bool
tags:
- nova-powervm-libs
- name: Register nova_powervm module path (no venv)
command: python -c 'import nova_powervm; print nova_powervm.__file__'
register: nova_powervm_module_path
when:
- not nova_venv_enabled | bool
tags:
- nova-powervm-libs
- name: Link nova_powervm module into the nova virt (no venv)
file: file:
src: "{{ nova_powervm_module_path.stdout | dirname }}/virt/powervm" src: "{{ nova_bin | dirname }}/lib/python2.7/site-packages/nova_powervm/virt/powervm"
dest: "{{ nova_module_path.stdout | dirname }}/virt/powervm" dest: "{{ nova_bin | dirname }}/lib/python2.7/site-packages/nova/virt/powervm"
state: link state: link
force: "yes" force: "yes"
when:
- not nova_venv_enabled | bool
tags:
- nova-powervm-libs
- name: Link nova_powervm module into the nova virt (venv)
file:
src: "{{ nova_venv_bin | dirname }}/lib/python2.7/site-packages/nova_powervm/virt/powervm"
dest: "{{ nova_venv_bin | dirname }}/lib/python2.7/site-packages/nova/virt/powervm"
state: link
force: "yes"
when:
- nova_venv_enabled | bool
tags: tags:
- nova-powervm-libs - nova-powervm-libs

View File

@ -38,11 +38,11 @@
- nova-install - nova-install
- nova-novnc-git - nova-novnc-git
- name: Install pip packages (venv) - name: Install pip packages
pip: pip:
name: "{{ item }}" name: "{{ item }}"
state: latest state: latest
virtualenv: "{{ nova_venv_bin | dirname }}" virtualenv: "{{ nova_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
@ -51,27 +51,11 @@
delay: 2 delay: 2
with_items: "{{ nova_novnc_pip_packages }}" with_items: "{{ nova_novnc_pip_packages }}"
when: when:
- nova_venv_enabled | bool
- nova_get_venv | failed or nova_developer_mode | bool - nova_get_venv | failed or nova_developer_mode | bool
tags: tags:
- nova-install - nova-install
- nova-pip-packages - nova-pip-packages
- name: Install 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
with_items: "{{ nova_novnc_pip_packages }}"
when: not nova_venv_enabled | bool
tags:
- nova-install
- nova-novnc-pip-packages
- include: nova_console_novnc_ssl.yml - include: nova_console_novnc_ssl.yml
when: nova_console_user_ssl_cert is defined and nova_console_user_ssl_key is defined when: nova_console_user_ssl_cert is defined and nova_console_user_ssl_key is defined
tags: tags:

View File

@ -95,7 +95,6 @@
get_md5: False get_md5: False
when: when:
- not nova_developer_mode | bool - not nova_developer_mode | bool
- nova_venv_enabled | bool
register: local_venv_stat register: local_venv_stat
tags: tags:
- nova-install - nova-install
@ -107,7 +106,6 @@
return_content: True return_content: True
when: when:
- not nova_developer_mode | bool - not nova_developer_mode | bool
- nova_venv_enabled | bool
register: remote_venv_checksum register: remote_venv_checksum
tags: tags:
- nova-install - nova-install
@ -127,7 +125,6 @@
register: get_venv register: get_venv
when: when:
- not nova_developer_mode | bool - not nova_developer_mode | bool
- nova_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:
@ -137,17 +134,15 @@
- name: Set nova get_venv fact - name: Set nova get_venv fact
set_fact: set_fact:
nova_get_venv: "{{ get_venv }}" nova_get_venv: "{{ get_venv }}"
when: nova_venv_enabled | bool
tags: tags:
- nova-install - nova-install
- nova-pip-packages - nova-pip-packages
- name: Remove existing venv - name: Remove existing venv
file: file:
path: "{{ nova_venv_bin | dirname }}" path: "{{ nova_bin | dirname }}"
state: absent state: absent
when: when:
- nova_venv_enabled | bool
- nova_get_venv | changed - nova_get_venv | changed
tags: tags:
- nova-install - nova-install
@ -155,12 +150,9 @@
- name: Create nova venv dir - name: Create nova venv dir
file: file:
path: "{{ nova_venv_bin | dirname }}" path: "{{ nova_bin | dirname }}"
state: directory state: directory
when: register: nova_venv_dir
- not nova_developer_mode | bool
- nova_venv_enabled | bool
- nova_get_venv | changed
tags: tags:
- nova-install - nova-install
- nova-pip-packages - nova-pip-packages
@ -168,33 +160,21 @@
- name: Unarchive pre-built venv - name: Unarchive pre-built venv
unarchive: unarchive:
src: "/var/cache/{{ nova_venv_download_url | basename }}" src: "/var/cache/{{ nova_venv_download_url | basename }}"
dest: "{{ nova_venv_bin | dirname }}" dest: "{{ nova_bin | dirname }}"
copy: "no" copy: "no"
when: when:
- not nova_developer_mode | bool - not nova_developer_mode | bool
- nova_venv_enabled | bool - nova_get_venv | changed or nova_venv_dir | changed
- nova_get_venv | changed
notify: Restart nova services notify: Restart nova services
tags: tags:
- nova-install - nova-install
- nova-pip-packages - nova-pip-packages
- name: Update virtualenv path - name: Install pip packages
command: >
virtualenv-tools --update-path=auto {{ nova_venv_bin | dirname }}
when:
- not nova_developer_mode | bool
- nova_venv_enabled | bool
- nova_get_venv | success
tags:
- nova-install
- nova-pip-packages
- name: Install pip packages (venv)
pip: pip:
name: "{{ item }}" name: "{{ item }}"
state: latest state: latest
virtualenv: "{{ nova_venv_bin | dirname }}" virtualenv: "{{ nova_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
@ -203,27 +183,18 @@
delay: 2 delay: 2
with_items: "{{ nova_pip_packages }}" with_items: "{{ nova_pip_packages }}"
when: when:
- nova_venv_enabled | bool
- nova_get_venv | failed or nova_developer_mode | bool - nova_get_venv | failed or nova_developer_mode | bool
notify: Restart nova services notify: Restart nova services
tags: tags:
- nova-install - nova-install
- nova-pip-packages - nova-pip-packages
- name: Install pip packages (no venv) - name: Update virtualenv path
pip: command: >
name: "{{ item }}" virtualenv-tools --update-path=auto {{ nova_bin | dirname }}
state: latest
extra_args: "{{ pip_install_options_fact }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
with_items: "{{ nova_pip_packages }}"
when: when:
- not nova_developer_mode | bool - not nova_developer_mode | bool
- not nova_venv_enabled | bool - nova_get_venv | success
notify: Restart nova services
tags: tags:
- nova-install - nova-install
- nova-pip-packages - nova-pip-packages

View File

@ -75,22 +75,6 @@
- nova-config - nova-config
- nova-post-install - nova-post-install
- name: Get nova command path
command: which nova
register: nova_command_path
when:
- not nova_venv_enabled | bool
tags:
- nova-command-bin
- name: Set nova command path
set_fact:
nova_bin: "{{ nova_command_path.stdout | dirname }}"
when:
- not nova_venv_enabled | bool
tags:
- nova-command-bin
- name: Drop sudoers file - name: Drop sudoers file
template: template:
src: "sudoers.j2" src: "sudoers.j2"

View File

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

View File

@ -23,9 +23,7 @@ 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 nova_venv_enabled | bool -%} . {{ nova_bin }}/activate
. {{ nova_venv_bin }}/activate
{%- endif %}
end script end script

View File

@ -114,7 +114,7 @@ nova_service_project_name: service
nova_service_region: RegionOne nova_service_region: RegionOne
nova_service_user_domain_id: default nova_service_user_domain_id: default
nova_service_user_name: nova nova_service_user_name: nova
nova_venv_bin: "/openstack/venvs/nova-{{ nova_venv_tag }}/bin" nova_bin: "/openstack/venvs/nova-{{ nova_venv_tag }}/bin"
nova_venv_tag: "testing" nova_venv_tag: "testing"
nova_virt_type: qemu nova_virt_type: qemu
openrc_os_auth_url: "http://127.0.0.1:5000/v3" openrc_os_auth_url: "http://127.0.0.1:5000/v3"