
In order to ensure that the build tasks are entirely skipped when a package venv is re-used, the build and install stages are split. The ability to re-use venvs is also now able to be toggled. Disabling this feature would set the build to always happen, catering to environments where a service venv is always deployed to the same folder (eg: stateless hypervisors with squashfs partitions). The ability to set constraints, etc is changed to a generalised set of arguments that can be passed to the pip install task.
54 lines
1.8 KiB
YAML
54 lines
1.8 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 }}.checksum"
|
|
dest: "{{ venv_destination_path | dirname }}"
|
|
register: _venv_checksum_copy
|
|
- _src_venv_present.stat.exists | bool
|
|
|
|
- name: Remove existing venv on target host if it is changing
|
|
file:
|
|
path: "{{ venv_destination_path }}"
|
|
state: absent
|
|
- _venv_checksum_copy is mapping
|
|
- _venv_checksum_copy | changed
|
|
|
|
- name: Create venv directory on the target host
|
|
file:
|
|
path: "{{ venv_destination_path }}"
|
|
state: directory
|
|
|
|
- name: Unarchive pre-built venv
|
|
unarchive:
|
|
src: "{{ venv_reuse_download_path }}/{{ venv_destination_path }}.tgz"
|
|
dest: "{{ venv_destination_path }}"
|
|
remote_src: no
|
|
- _venv_checksum_copy is mapping
|
|
- _venv_checksum_copy | 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
|