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
This commit is contained in:
Jesse Pretorius 2016-11-07 11:34:16 +00:00 committed by Jesse Pretorius (odyssey4me)
parent b2e3a67c44
commit 07505b47a6
2 changed files with 7 additions and 23 deletions

View File

@ -4,7 +4,7 @@ galaxy_info:
description: Installation and setup of sahara description: Installation and setup of sahara
company: LSD/UFCG company: LSD/UFCG
license: Apache2 license: Apache2
min_ansible_version: 1.9.4 min_ansible_version: 2.0
platforms: platforms:
- name: Ubuntu - name: Ubuntu
versions: versions:

View File

@ -37,34 +37,19 @@
retries: 5 retries: 5
delay: 2 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 - name: Attempt venv download
get_url: get_url:
url: "{{ sahara_venv_download_url }}" url: "{{ sahara_venv_download_url }}"
dest: "/var/cache/{{ sahara_venv_download_url | basename }}" dest: "/var/cache/{{ sahara_venv_download_url | basename }}"
checksum: "sha1:{{ remote_venv_checksum.content }}" checksum: "sha1:{{ lookup('url', sahara_venv_download_url | replace('tgz', 'checksum')) }}"
failed_when: false register: sahara_get_venv
register: get_venv when: not sahara_developer_mode | bool
when:
- not sahara_developer_mode | bool
- name: Set sahara get_venv fact
set_fact:
sahara_get_venv: "{{ get_venv }}"
- name: Remove existing venv - name: Remove existing venv
file: file:
path: "{{ sahara_bin | dirname }}" path: "{{ sahara_bin | dirname }}"
state: absent state: absent
when: when: sahara_get_venv | changed
- sahara_get_venv | changed
- name: Create sahara venv dir - name: Create sahara venv dir
file: file:
@ -97,8 +82,7 @@
until: install_packages|success until: install_packages|success
retries: 5 retries: 5
delay: 2 delay: 2
when: when: sahara_developer_mode | bool
- sahara_get_venv | failed or sahara_developer_mode | bool
notify: notify:
- Restart sahara services - Restart sahara services
@ -107,4 +91,4 @@
virtualenv-tools --update-path=auto {{ sahara_bin | dirname }} virtualenv-tools --update-path=auto {{ sahara_bin | dirname }}
when: when:
- not sahara_developer_mode | bool - not sahara_developer_mode | bool
- sahara_get_venv | success - sahara_get_venv | changed or sahara_venv_dir | changed