Only install to virtual environment

Remove all tasks and variables related to toggling between installation
of magnum 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: Ida3320575e628076a1e9c99ba1b2bb04e7c3c4d8
Implements: blueprint only-install-venvs
This commit is contained in:
Anton Khaldin 2016-07-07 22:22:21 -07:00
parent b4ce21e4b0
commit 8b0f4f97c4
5 changed files with 20 additions and 53 deletions

View File

@ -46,15 +46,7 @@ magnum_api_paste_ini_overrides: {}
# Name of the virtual env to deploy into
magnum_venv_tag: untagged
magnum_venv_bin: "/openstack/venvs/magnum-{{ magnum_venv_tag }}/bin"
# Set this to enable or disable installing in a venv
magnum_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.
magnum_bin: "{{ magnum_venv_bin }}"
magnum_bin: "/openstack/venvs/magnum-{{ magnum_venv_tag }}/bin"
magnum_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/magnum.tgz

View File

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

View File

@ -14,7 +14,7 @@
# limitations under the License.
- name: Perform a synchronization of the Magnum database
command: "{{ magnum_venv_bin}}/magnum-db-manage upgrade"
command: "{{ magnum_bin}}/magnum-db-manage upgrade"
become: yes
become_user: "{{ magnum_system_user_name }}"
tags:

View File

@ -84,7 +84,6 @@
get_md5: False
when:
- not magnum_developer_mode | bool
- magnum_venv_enabled | bool
register: local_venv_stat
tags:
- magnum-install
@ -96,7 +95,6 @@
return_content: True
when:
- not magnum_developer_mode | bool
- magnum_venv_enabled | bool
register: remote_venv_checksum
tags:
- magnum-install
@ -116,7 +114,6 @@
register: get_venv
when:
- not magnum_developer_mode | bool
- magnum_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 magnum get_venv fact
set_fact:
magnum_get_venv: "{{ get_venv }}"
when: magnum_venv_enabled | bool
tags:
- magnum-install
- magnum-pip-packages
- name: Remove existing venv
file:
path: "{{ magnum_venv_bin | dirname }}"
path: "{{ magnum_bin | dirname }}"
state: absent
when:
- magnum_venv_enabled | bool
- magnum_get_venv | changed
tags:
- magnum-install
@ -144,12 +139,9 @@
- name: Create magnum venv dir
file:
path: "{{ magnum_venv_bin | dirname }}"
path: "{{ magnum_bin | dirname }}"
state: directory
when:
- not magnum_developer_mode | bool
- magnum_venv_enabled | bool
- magnum_get_venv | changed
register: magnum_venv_dir
tags:
- magnum-install
- magnum-pip-packages
@ -157,33 +149,21 @@
- name: Unarchive pre-built venv
unarchive:
src: "/var/cache/{{ magnum_venv_download_url | basename }}"
dest: "{{ magnum_venv_bin | dirname }}"
dest: "{{ magnum_bin | dirname }}"
copy: "no"
when:
- not magnum_developer_mode | bool
- magnum_venv_enabled | bool
- magnum_get_venv | changed
- magnum_get_venv | changed or magnum_venv_dir | changed
notify: Restart magnum services
tags:
- magnum-install
- magnum-pip-packages
- name: Update virtualenv path
command: >
virtualenv-tools --update-path=auto {{ magnum_venv_bin | dirname }}
when:
- not magnum_developer_mode | bool
- magnum_venv_enabled | bool
- magnum_get_venv | success
tags:
- magnum-install
- magnum-pip-packages
- name: Install pip packages (venv)
- name: Install pip packages
pip:
name: "{{ item }}"
state: latest
virtualenv: "{{ magnum_venv_bin | dirname }}"
virtualenv: "{{ magnum_bin | dirname }}"
virtualenv_site_packages: "no"
extra_args: "{{ pip_install_options_fact }}"
register: install_packages
@ -192,27 +172,19 @@
delay: 2
with_items: "{{ magnum_pip_packages }}"
when:
- magnum_venv_enabled | bool
- magnum_get_venv | failed or magnum_developer_mode | bool
notify: Restart magnum services
tags:
- magnum-install
- magnum-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: "{{ magnum_pip_packages }}"
- name: Update virtualenv path
command: >
virtualenv-tools --update-path=auto {{ magnum_bin | dirname }}
when:
- not magnum_developer_mode | bool
- not magnum_venv_enabled | bool
notify: Restart magnum services
- magnum_get_venv | success
tags:
- magnum-install
- magnum-pip-packages

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 magnum_venv_enabled | bool -%}
. {{ magnum_venv_bin }}/activate
{%- endif %}
. {{ magnum_bin }}/activate
end script