From 2f1291bf55687dddcce23b344319fa204b06a500 Mon Sep 17 00:00:00 2001 From: Logan V Date: Fri, 13 Jan 2017 19:52:42 -0600 Subject: [PATCH] Clean up developer mode logic Fixes the ability to deploy a venv in cases where: 1) developer_mode is not enabled 2) A cached venv is not downloaded from the repo server Additional cleanup to the developer_mode venv deployment logic is implemented by adding a *_venv_download var which is used to decouple developer_mode from the cached venv extraction process so that a deployer can force venv builds in-place (disable cached venv usage) without enabling developer mode constraints. Change-Id: Ie19e4e035e5944a984026024aaeebf72313779d2 --- defaults/main.yml | 3 +++ tasks/swift_install.yml | 27 +++++++-------------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 30303058..a7aa4bfe 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -35,6 +35,9 @@ swift_developer_constraints: swift_venv_tag: untagged swift_bin: "/openstack/venvs/swift-{{ swift_venv_tag }}/bin" +# venv_download, even when true, will use the fallback method of building the +# venv from scratch if the venv download fails. +swift_venv_download: "{{ not swift_developer_mode | bool and not swift_pypy_enabled | bool }}" swift_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/swift.tgz # Set the full path to the swift recon cron diff --git a/tasks/swift_install.yml b/tasks/swift_install.yml index 9b88d10f..96f0858b 100644 --- a/tasks/swift_install.yml +++ b/tasks/swift_install.yml @@ -69,33 +69,27 @@ dest: "/var/cache/{{ swift_venv_download_url | basename }}" checksum: "sha1:{{ lookup('url', swift_venv_download_url | replace('tgz', 'checksum')) }}" register: swift_get_venv - when: - - not swift_pypy_enabled | bool - - not swift_developer_mode | bool + when: swift_venv_download | bool - name: Remove existing venv file: path: "{{ swift_bin | dirname }}" state: absent - when: - - not swift_pypy_enabled | bool - - swift_get_venv | changed + when: swift_get_venv | changed - name: Create swift venv dir file: path: "{{ swift_bin | dirname }}" state: directory register: swift_venv_dir + when: swift_get_venv | changed - name: Unarchive pre-built venv unarchive: src: "/var/cache/{{ swift_venv_download_url | basename }}" dest: "{{ swift_bin | dirname }}" copy: "no" - when: - - not swift_pypy_enabled | bool - - not swift_developer_mode | bool - - swift_get_venv | changed or swift_venv_dir | changed + when: swift_get_venv | changed notify: - Restart swift services @@ -113,9 +107,7 @@ until: install_packages|success retries: 5 delay: 2 - when: - - not swift_pypy_enabled | bool - - swift_developer_mode | bool + when: swift_get_venv | failed or swift_get_venv | skipped notify: - Restart swift services @@ -125,17 +117,12 @@ state: "absent" when: - ansible_pkg_mgr == 'yum' - - not swift_pypy_enabled | bool - - not swift_developer_mode | bool - - swift_get_venv | changed or swift_venv_dir | changed + - swift_get_venv | changed - name: Update virtualenv path command: > virtualenv-tools --update-path=auto --reinitialize {{ swift_bin | dirname }} - when: - - not swift_pypy_enabled | bool - - not swift_developer_mode | bool - - swift_get_venv | changed or swift_venv_dir | changed + when: swift_get_venv | changed - include: swift_pypy_setup.yml static: no