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 # Name of the virtual env to deploy into
ironic_venv_tag: untagged ironic_venv_tag: untagged
ironic_venv_bin: "/openstack/venvs/ironic-{{ ironic_venv_tag }}/bin" ironic_bin: "/openstack/venvs/ironic-{{ ironic_venv_tag }}/bin"
# Set this to enable or disable installing in a venv
ironic_venv_enabled: True
# System info # System info
ironic_system_user_name: ironic ironic_system_user_name: ironic
@ -130,8 +127,6 @@ ironic_node_name: ironic
# regenerated each run. # regenerated each run.
ironic_recreate_keys: False ironic_recreate_keys: False
ironic_bin: "{{ ironic_venv_bin }}"
ironic_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/ironic.tgz ironic_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/ironic.tgz
ironic_tftp_server_address: "{{ ansible_ssh_host }}" 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 get_md5: False
when: when:
- not ironic_developer_mode | bool - not ironic_developer_mode | bool
- ironic_venv_enabled | bool
register: local_venv_stat register: local_venv_stat
tags: tags:
- ironic-install - ironic-install
@ -100,7 +99,6 @@
return_content: True return_content: True
when: when:
- not ironic_developer_mode | bool - not ironic_developer_mode | bool
- ironic_venv_enabled | bool
register: remote_venv_checksum register: remote_venv_checksum
tags: tags:
- ironic-install - ironic-install
@ -120,7 +118,6 @@
register: get_venv register: get_venv
when: when:
- not ironic_developer_mode | bool - not ironic_developer_mode | bool
- ironic_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:
@ -130,17 +127,15 @@
- name: Set ironic get_venv fact - name: Set ironic get_venv fact
set_fact: set_fact:
ironic_get_venv: "{{ get_venv }}" ironic_get_venv: "{{ get_venv }}"
when: ironic_venv_enabled | bool
tags: tags:
- ironic-install - ironic-install
- ironic-pip-packages - ironic-pip-packages
- name: Remove existing venv - name: Remove existing venv
file: file:
path: "{{ ironic_venv_bin | dirname }}" path: "{{ ironic_bin | dirname }}"
state: absent state: absent
when: when:
- ironic_venv_enabled | bool
- ironic_get_venv | changed - ironic_get_venv | changed
tags: tags:
- ironic-install - ironic-install
@ -148,12 +143,9 @@
- name: Create ironic venv dir - name: Create ironic venv dir
file: file:
path: "{{ ironic_venv_bin | dirname }}" path: "{{ ironic_bin | dirname }}"
state: directory state: directory
when: register: ironic_venv_dir
- not ironic_developer_mode | bool
- ironic_venv_enabled | bool
- ironic_get_venv | changed
tags: tags:
- ironic-install - ironic-install
- ironic-pip-packages - ironic-pip-packages
@ -161,33 +153,21 @@
- name: Unarchive pre-built venv - name: Unarchive pre-built venv
unarchive: unarchive:
src: "/var/cache/{{ ironic_venv_download_url | basename }}" src: "/var/cache/{{ ironic_venv_download_url | basename }}"
dest: "{{ ironic_venv_bin | dirname }}" dest: "{{ ironic_bin | dirname }}"
copy: "no" copy: "no"
when: when:
- not ironic_developer_mode | bool - not ironic_developer_mode | bool
- ironic_venv_enabled | bool - ironic_get_venv | changed or ironic_venv_dir | changed
- ironic_get_venv | changed
notify: Restart ironic services notify: Restart ironic services
tags: tags:
- ironic-install - ironic-install
- ironic-pip-packages - ironic-pip-packages
- name: Update virtualenv path - name: Install pip packages
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)
pip: pip:
name: "{{ item }}" name: "{{ item }}"
state: latest state: latest
virtualenv: "{{ ironic_venv_bin | dirname }}" virtualenv: "{{ ironic_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
@ -196,27 +176,18 @@
delay: 2 delay: 2
with_items: "{{ ironic_pip_packages }}" with_items: "{{ ironic_pip_packages }}"
when: when:
- ironic_venv_enabled | bool
- ironic_get_venv | failed or ironic_developer_mode | bool - ironic_get_venv | failed or ironic_developer_mode | bool
notify: Restart ironic services notify: Restart ironic services
tags: tags:
- ironic-install - ironic-install
- ironic-pip-packages - ironic-pip-packages
- name: Install pip packages (no venv) - name: Update virtualenv path
pip: command: >
name: "{{ item }}" virtualenv-tools --update-path=auto {{ ironic_bin | dirname }}
state: latest
extra_args: "{{ pip_install_options_fact }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
with_items: "{{ ironic_pip_packages }}"
when: when:
- not ironic_venv_enabled | bool
- not ironic_developer_mode | bool - not ironic_developer_mode | bool
notify: Restart ironic services - ironic_get_venv | success
tags: tags:
- ironic-install - ironic-install
- ironic-pip-packages - ironic-pip-packages

View File

@ -37,22 +37,6 @@
tags: tags:
- always - 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 - name: Post swift tempURL secret key
shell: | shell: |
OS_ENDPOINT_TYPE=internalURL \ OS_ENDPOINT_TYPE=internalURL \

View File

@ -75,18 +75,6 @@
- ironic-api - ironic-api
- ironic-conductor - 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 - name: Test for log directory or link
shell: | shell: |
if [ -h "{{ ironic_system_log_folder }}" ]; then if [ -h "{{ ironic_system_log_folder }}" ]; then

View File

@ -26,9 +26,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 ironic_venv_enabled | bool -%} . {{ ironic_bin }}/activate
. {{ ironic_venv_bin }}/activate
{%- endif %}
end script end script

View File

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