From 07505b47a6a448e59cc33fdfeb9e7d11c1fe1b8b Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Mon, 7 Nov 2016 11:34:16 +0000 Subject: [PATCH] Optimise venv fetch mechanism Unnecessary tasks are removed and the ability to ignore a venv download failure is removed as this is not necessary or desirable. It is better for the download to fail and the playbook execution to stop immediately so that the failure point is exposed. Change-Id: I2dbe74353e22368074bc3219605e9c4b2da896e8 --- meta/main.yml | 2 +- tasks/sahara_install.yml | 28 ++++++---------------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/meta/main.yml b/meta/main.yml index 38cb209..7c20352 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -4,7 +4,7 @@ galaxy_info: description: Installation and setup of sahara company: LSD/UFCG license: Apache2 - min_ansible_version: 1.9.4 + min_ansible_version: 2.0 platforms: - name: Ubuntu versions: diff --git a/tasks/sahara_install.yml b/tasks/sahara_install.yml index 2811732..b2e8037 100644 --- a/tasks/sahara_install.yml +++ b/tasks/sahara_install.yml @@ -37,34 +37,19 @@ retries: 5 delay: 2 -- name: Get remote venv checksum - uri: - url: "{{ sahara_venv_download_url | replace('tgz', 'checksum') }}" - return_content: True - when: - - not sahara_developer_mode | bool - register: remote_venv_checksum - - name: Attempt venv download get_url: url: "{{ sahara_venv_download_url }}" dest: "/var/cache/{{ sahara_venv_download_url | basename }}" - checksum: "sha1:{{ remote_venv_checksum.content }}" - failed_when: false - register: get_venv - when: - - not sahara_developer_mode | bool - -- name: Set sahara get_venv fact - set_fact: - sahara_get_venv: "{{ get_venv }}" + checksum: "sha1:{{ lookup('url', sahara_venv_download_url | replace('tgz', 'checksum')) }}" + register: sahara_get_venv + when: not sahara_developer_mode | bool - name: Remove existing venv file: path: "{{ sahara_bin | dirname }}" state: absent - when: - - sahara_get_venv | changed + when: sahara_get_venv | changed - name: Create sahara venv dir file: @@ -97,8 +82,7 @@ until: install_packages|success retries: 5 delay: 2 - when: - - sahara_get_venv | failed or sahara_developer_mode | bool + when: sahara_developer_mode | bool notify: - Restart sahara services @@ -107,4 +91,4 @@ virtualenv-tools --update-path=auto {{ sahara_bin | dirname }} when: - not sahara_developer_mode | bool - - sahara_get_venv | success + - sahara_get_venv | changed or sahara_venv_dir | changed