
In the situation where a deployer may have removed the venv folder on the target host, but has not removed the the tgz/checksum file, the venv will not be extracted again. This patch ensures that if the venv folder was not there and gets created by the task then it will extract the tgz into the folder.
58 lines
1.9 KiB
YAML
58 lines
1.9 KiB
YAML
---
|
|
# Copyright 2018, Rackspace US, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
- name: Copy the venv checksum file to the target host
|
|
copy:
|
|
src: "{{ venv_reuse_download_path }}/{{ venv_destination_path | basename }}.checksum"
|
|
dest: "{{ venv_destination_path | dirname }}"
|
|
register: _venv_checksum_copy
|
|
when:
|
|
- _src_venv_present.stat.exists | bool
|
|
|
|
- name: Remove existing venv on target host if it is changing
|
|
file:
|
|
path: "{{ venv_destination_path }}"
|
|
state: absent
|
|
when:
|
|
- _venv_checksum_copy is mapping
|
|
- _venv_checksum_copy | changed
|
|
|
|
- name: Create venv directory on the target host
|
|
file:
|
|
path: "{{ venv_destination_path }}"
|
|
state: directory
|
|
register: _venv_dir_create
|
|
|
|
- name: Unarchive pre-built venv
|
|
unarchive:
|
|
src: "{{ venv_reuse_download_path }}/{{ venv_destination_path | basename }}.tgz"
|
|
dest: "{{ venv_destination_path }}"
|
|
remote_src: no
|
|
when:
|
|
- (_venv_checksum_copy is mapping and _venv_checksum_copy | changed) or
|
|
_venv_dir_create | changed
|
|
notify:
|
|
- venv changed
|
|
|
|
- name: Update virtualenv python and paths
|
|
shell: |
|
|
sed -si '1s/^.*python.*$/#!{{ (venv_destination_path ~ '/bin') | replace ('/','\/') }}\/python/' {{ venv_destination_path }}/bin/*
|
|
virtualenv {{ venv_destination_path }}
|
|
when:
|
|
- _venv_checksum_copy is mapping
|
|
- _venv_checksum_copy | changed
|
|
tags:
|
|
- skip_ansible_lint
|