From df3b47973a6b0a206e11d5ab3978f5fb361f1f7a Mon Sep 17 00:00:00 2001 From: Travis Truman Date: Thu, 7 Jul 2016 12:59:19 -0400 Subject: [PATCH] Only install to virtual environment Remove all tasks and variables related to toggling between installation of cinder 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: I21ebc977f3c6d97853150e8b42bcd35ab4c2ef09 Implements: blueprint only-install-venvs --- defaults/main.yml | 10 +--- ...er-only-install-venv-914d5655dd645213.yaml | 5 ++ tasks/cinder_install.yml | 47 ++++--------------- tasks/cinder_post_install.yml | 16 ------- tasks/cinder_pre_install.yml | 11 ----- templates/cinder-upstart-init.j2 | 4 +- tests/test-vars.yml | 1 - 7 files changed, 17 insertions(+), 77 deletions(-) create mode 100644 releasenotes/notes/os_cinder-only-install-venv-914d5655dd645213.yaml diff --git a/defaults/main.yml b/defaults/main.yml index 721b4f8b..a7e1dbd4 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -24,15 +24,7 @@ cinder_developer_constraints: # Name of the virtual env to deploy into cinder_venv_tag: untagged -cinder_venv_bin: "/openstack/venvs/cinder-{{ cinder_venv_tag }}/bin" - -# Set this to enable or disable installing in a venv -cinder_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. -cinder_bin: "{{ cinder_venv_bin }}" +cinder_bin: "/openstack/venvs/cinder-{{ cinder_venv_tag }}/bin" cinder_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/cinder.tgz diff --git a/releasenotes/notes/os_cinder-only-install-venv-914d5655dd645213.yaml b/releasenotes/notes/os_cinder-only-install-venv-914d5655dd645213.yaml new file mode 100644 index 00000000..9bd86d67 --- /dev/null +++ b/releasenotes/notes/os_cinder-only-install-venv-914d5655dd645213.yaml @@ -0,0 +1,5 @@ +--- +upgrade: + - Installation of cinder and its dependent pip packages will now only + occur within a Python virtual environment. The ``cinder_venv_enabled`` + and ``cinder_venv_bin`` variables have been removed. \ No newline at end of file diff --git a/tasks/cinder_install.yml b/tasks/cinder_install.yml index 6e11644a..470aa993 100644 --- a/tasks/cinder_install.yml +++ b/tasks/cinder_install.yml @@ -84,7 +84,6 @@ get_md5: False when: - not cinder_developer_mode | bool - - cinder_venv_enabled | bool register: local_venv_stat tags: - cinder-install @@ -96,7 +95,6 @@ return_content: True when: - not cinder_developer_mode | bool - - cinder_venv_enabled | bool register: remote_venv_checksum tags: - cinder-install @@ -116,7 +114,6 @@ register: get_venv when: - not cinder_developer_mode | bool - - cinder_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 cinder get_venv fact set_fact: cinder_get_venv: "{{ get_venv }}" - when: cinder_venv_enabled | bool tags: - cinder-install - cinder-pip-packages - name: Remove existing venv file: - path: "{{ cinder_venv_bin | dirname }}" + path: "{{ cinder_bin | dirname }}" state: absent when: - - cinder_venv_enabled | bool - cinder_get_venv | changed tags: - cinder-install @@ -144,11 +139,11 @@ - name: Create cinder venv dir file: - path: "{{ cinder_venv_bin | dirname }}" + path: "{{ cinder_bin | dirname }}" state: directory + register: cinder_venv_dir when: - not cinder_developer_mode | bool - - cinder_venv_enabled | bool - cinder_get_venv | changed tags: - cinder-install @@ -157,33 +152,21 @@ - name: Unarchive pre-built venv unarchive: src: "/var/cache/{{ cinder_venv_download_url | basename }}" - dest: "{{ cinder_venv_bin | dirname }}" + dest: "{{ cinder_bin | dirname }}" copy: "no" when: - not cinder_developer_mode | bool - - cinder_venv_enabled | bool - - cinder_get_venv | changed + - cinder_get_venv | changed or cinder_venv_dir | changed notify: Restart cinder services tags: - cinder-install - cinder-pip-packages -- name: Update virtualenv path - command: > - virtualenv-tools --update-path=auto {{ cinder_venv_bin | dirname }} - when: - - not cinder_developer_mode | bool - - cinder_venv_enabled | bool - - cinder_get_venv | success - tags: - - cinder-install - - cinder-pip-packages - -- name: Install pip packages (venv) +- name: Install pip packages pip: name: "{{ item }}" state: latest - virtualenv: "{{ cinder_venv_bin | dirname }}" + virtualenv: "{{ cinder_bin | dirname }}" virtualenv_site_packages: "no" extra_args: "{{ pip_install_options_fact }}" register: install_packages @@ -192,27 +175,17 @@ delay: 2 with_items: "{{ cinder_pip_packages }}" when: - - cinder_venv_enabled | bool - cinder_get_venv | failed or cinder_developer_mode | bool notify: Restart cinder services tags: - cinder-install - cinder-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: "{{ cinder_pip_packages }}" +- name: Update virtualenv path + command: > + virtualenv-tools --update-path=auto {{ cinder_bin | dirname }} when: - not cinder_developer_mode | bool - - not cinder_venv_enabled | bool - notify: Restart cinder services tags: - cinder-install - cinder-pip-packages diff --git a/tasks/cinder_post_install.yml b/tasks/cinder_post_install.yml index 2dea259d..93cc8bbc 100644 --- a/tasks/cinder_post_install.yml +++ b/tasks/cinder_post_install.yml @@ -79,22 +79,6 @@ tags: - cinder-nfs -- name: Get cinder command path - command: which cinder - register: cinder_command_path - when: - - not cinder_venv_enabled | bool - tags: - - cinder-command-bin - -- name: Set cinder command path - set_fact: - cinder_bin: "{{ cinder_command_path.stdout | dirname }}" - when: - - not cinder_venv_enabled | bool - tags: - - cinder-command-bin - - name: Drop sudoers file template: src: "sudoers.j2" diff --git a/tasks/cinder_pre_install.yml b/tasks/cinder_pre_install.yml index fcc03bc7..fd0de503 100644 --- a/tasks/cinder_pre_install.yml +++ b/tasks/cinder_pre_install.yml @@ -49,17 +49,6 @@ tags: - cinder-dirs -- name: Create cinder venv dir - file: - path: "{{ item.path }}" - state: directory - with_items: - - { path: "/openstack/venvs" } - - { path: "{{ cinder_venv_bin }}" } - when: cinder_venv_enabled | bool - tags: - - cinder-dirs - - name: Test for log directory or link shell: | if [ -h "/var/log/cinder" ]; then diff --git a/templates/cinder-upstart-init.j2 b/templates/cinder-upstart-init.j2 index cb03d287..11055947 100644 --- a/templates/cinder-upstart-init.j2 +++ b/templates/cinder-upstart-init.j2 @@ -23,9 +23,7 @@ pre-start script mkdir -p "/var/lock/{{ program_name }}" chown {{ system_user }}:{{ system_group }} "/var/lock/{{ program_name }}" - {% if cinder_venv_enabled | bool -%} - . {{ cinder_venv_bin }}/activate - {%- endif %} + . {{ cinder_bin }}/activate end script diff --git a/tests/test-vars.yml b/tests/test-vars.yml index 81407481..c3fbbfd0 100644 --- a/tests/test-vars.yml +++ b/tests/test-vars.yml @@ -16,7 +16,6 @@ cinder_galera_user: cinder cinder_galera_database: cinder cinder_requirements_git_install_branch: master cinder_service_password: "secrete" -cinder_venv_bin: "/openstack/venvs/cinder-{{ cinder_venv_tag }}/bin" cinder_venv_tag: "testing" debug: true external_lb_vip_address: 10.100.100.3