From e3004ccd158b8d2f4eeb40457b02e800ba10beb4 Mon Sep 17 00:00:00 2001 From: Jimmy McCrory Date: Thu, 7 Jul 2016 17:16:01 -0700 Subject: [PATCH] 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 --- defaults/main.yml | 7 +-- ...ic-only-install-venv-0da32fc36bfeae2b.yaml | 5 ++ tasks/ironic_install.yml | 51 ++++--------------- tasks/ironic_post_install.yml | 16 ------ tasks/ironic_pre_install.yml | 12 ----- templates/ironic-upstart-init.j2 | 4 +- templates/ironic-wsgi.py.j2 | 4 +- 7 files changed, 19 insertions(+), 80 deletions(-) create mode 100644 releasenotes/notes/os-ironic-only-install-venv-0da32fc36bfeae2b.yaml diff --git a/defaults/main.yml b/defaults/main.yml index 15dc5d78..36883b9d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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 }}" diff --git a/releasenotes/notes/os-ironic-only-install-venv-0da32fc36bfeae2b.yaml b/releasenotes/notes/os-ironic-only-install-venv-0da32fc36bfeae2b.yaml new file mode 100644 index 00000000..d39cc63c --- /dev/null +++ b/releasenotes/notes/os-ironic-only-install-venv-0da32fc36bfeae2b.yaml @@ -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. diff --git a/tasks/ironic_install.yml b/tasks/ironic_install.yml index a54d1aaa..43914136 100644 --- a/tasks/ironic_install.yml +++ b/tasks/ironic_install.yml @@ -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 diff --git a/tasks/ironic_post_install.yml b/tasks/ironic_post_install.yml index 210bbaae..ac20785b 100644 --- a/tasks/ironic_post_install.yml +++ b/tasks/ironic_post_install.yml @@ -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 \ diff --git a/tasks/ironic_pre_install.yml b/tasks/ironic_pre_install.yml index fa4d3b93..a23e6df3 100644 --- a/tasks/ironic_pre_install.yml +++ b/tasks/ironic_pre_install.yml @@ -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 diff --git a/templates/ironic-upstart-init.j2 b/templates/ironic-upstart-init.j2 index 405973e7..948083e9 100644 --- a/templates/ironic-upstart-init.j2 +++ b/templates/ironic-upstart-init.j2 @@ -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 diff --git a/templates/ironic-wsgi.py.j2 b/templates/ironic-wsgi.py.j2 index 64779a56..08e607de 100644 --- a/templates/ironic-wsgi.py.j2 +++ b/templates/ironic-wsgi.py.j2 @@ -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