Only install to virtual environment

Remove all tasks and variables related to toggling between installation
of ironic 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: I9df953f69eb86606ce8a6fe9f77e60c710549b8e
Implements: blueprint only-install-venvs
This commit is contained in:
Jimmy McCrory 2016-07-07 17:16:01 -07:00 committed by Anton Khaldin
parent 8b3f346921
commit e3004ccd15
7 changed files with 19 additions and 80 deletions

View File

@ -31,10 +31,7 @@ ironic_developer_constraints:
# Name of the virtual env to deploy into
ironic_venv_tag: untagged
ironic_venv_bin: "/openstack/venvs/ironic-{{ ironic_venv_tag }}/bin"
# Set this to enable or disable installing in a venv
ironic_venv_enabled: True
ironic_bin: "/openstack/venvs/ironic-{{ ironic_venv_tag }}/bin"
# System info
ironic_system_user_name: ironic
@ -130,8 +127,6 @@ ironic_node_name: ironic
# regenerated each run.
ironic_recreate_keys: False
ironic_bin: "{{ ironic_venv_bin }}"
ironic_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/ironic.tgz
ironic_tftp_server_address: "{{ ansible_ssh_host }}"

View File

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

View File

@ -88,7 +88,6 @@
get_md5: False
when:
- not ironic_developer_mode | bool
- ironic_venv_enabled | bool
register: local_venv_stat
tags:
- ironic-install
@ -100,7 +99,6 @@
return_content: True
when:
- not ironic_developer_mode | bool
- ironic_venv_enabled | bool
register: remote_venv_checksum
tags:
- ironic-install
@ -120,7 +118,6 @@
register: get_venv
when:
- not ironic_developer_mode | bool
- ironic_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:
@ -130,17 +127,15 @@
- name: Set ironic get_venv fact
set_fact:
ironic_get_venv: "{{ get_venv }}"
when: ironic_venv_enabled | bool
tags:
- ironic-install
- ironic-pip-packages
- name: Remove existing venv
file:
path: "{{ ironic_venv_bin | dirname }}"
path: "{{ ironic_bin | dirname }}"
state: absent
when:
- ironic_venv_enabled | bool
- ironic_get_venv | changed
tags:
- ironic-install
@ -148,12 +143,9 @@
- name: Create ironic venv dir
file:
path: "{{ ironic_venv_bin | dirname }}"
path: "{{ ironic_bin | dirname }}"
state: directory
when:
- not ironic_developer_mode | bool
- ironic_venv_enabled | bool
- ironic_get_venv | changed
register: ironic_venv_dir
tags:
- ironic-install
- ironic-pip-packages
@ -161,33 +153,21 @@
- name: Unarchive pre-built venv
unarchive:
src: "/var/cache/{{ ironic_venv_download_url | basename }}"
dest: "{{ ironic_venv_bin | dirname }}"
dest: "{{ ironic_bin | dirname }}"
copy: "no"
when:
- not ironic_developer_mode | bool
- ironic_venv_enabled | bool
- ironic_get_venv | changed
- ironic_get_venv | changed or ironic_venv_dir | changed
notify: Restart ironic services
tags:
- ironic-install
- ironic-pip-packages
- name: Update virtualenv path
command: >
virtualenv-tools --update-path=auto {{ ironic_venv_bin | dirname }}
when:
- not ironic_developer_mode | bool
- ironic_venv_enabled | bool
- ironic_get_venv | success
tags:
- ironic-install
- ironic-pip-packages
- name: Install pip packages (venv)
- name: Install pip packages
pip:
name: "{{ item }}"
state: latest
virtualenv: "{{ ironic_venv_bin | dirname }}"
virtualenv: "{{ ironic_bin | dirname }}"
virtualenv_site_packages: "no"
extra_args: "{{ pip_install_options_fact }}"
register: install_packages
@ -196,27 +176,18 @@
delay: 2
with_items: "{{ ironic_pip_packages }}"
when:
- ironic_venv_enabled | bool
- ironic_get_venv | failed or ironic_developer_mode | bool
notify: Restart ironic services
tags:
- ironic-install
- ironic-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: "{{ ironic_pip_packages }}"
- name: Update virtualenv path
command: >
virtualenv-tools --update-path=auto {{ ironic_bin | dirname }}
when:
- not ironic_venv_enabled | bool
- not ironic_developer_mode | bool
notify: Restart ironic services
- ironic_get_venv | success
tags:
- ironic-install
- ironic-pip-packages

View File

@ -37,22 +37,6 @@
tags:
- always
- name: Get ironic command path
command: which ironic
register: ironic_command_path
when:
- not ironic_venv_enabled | bool
tags:
- ironic-command-bin
- name: Set ironic command path
set_fact:
ironic_bin: "{{ ironic_command_path.stdout | dirname }}"
when:
- not ironic_venv_enabled | bool
tags:
- ironic-command-bin
- name: Post swift tempURL secret key
shell: |
OS_ENDPOINT_TYPE=internalURL \

View File

@ -75,18 +75,6 @@
- ironic-api
- ironic-conductor
- name: Create ironic venv dir
file:
path: "{{ item.path }}"
state: directory
with_items:
- { path: "/openstack/venvs" }
- { path: "{{ ironic_venv_bin }}" }
when: ironic_venv_enabled | bool
tags:
- ironic-api
- ironic-conductor
- name: Test for log directory or link
shell: |
if [ -h "{{ ironic_system_log_folder }}" ]; then

View File

@ -26,9 +26,7 @@ pre-start script
mkdir -p "/var/lock/{{ program_name }}"
chown {{ system_user }}:{{ system_group }} "/var/lock/{{ program_name }}"
{% if ironic_venv_enabled | bool -%}
. {{ ironic_venv_bin }}/activate
{%- endif %}
. {{ ironic_bin }}/activate
end script

View File

@ -18,10 +18,8 @@
import os
{% if ironic_venv_enabled | bool %}
activate_this = os.path.expanduser("{{ ironic_venv_bin }}/activate_this.py")
activate_this = os.path.expanduser("{{ ironic_bin }}/activate_this.py")
execfile(activate_this, dict(__file__=activate_this))
{% endif %}
import logging
import sys