ansible-role-python_venv_build/tasks/python_venv_preflight.yml

67 lines
2.1 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: Verify that venv_destination_path has been provided
fail:
msg: |
The variable venv_destination_path is required and
has not been set
when:
- venv_destination_path is not defined
- name: Verify that venv_reuse_enable and venv_reuse_build_only are not interfering with each other
fail:
msg: |
If venv_reuse_build_only is enabled, then venv_reuse_enable must also
be enabled.
The variable venv_reuse_enable is set to {{ venv_reuse_enable }}.
The variable venv_reuse_build_only is set to {{ venv_reuse_build_only }}.
when:
- venv_reuse_build_only | bool
- not venv_reuse_enable | bool
- name: Ensure that venv_reuse_download_path exists on the deployment host
file:
path: "{{ venv_reuse_download_path }}"
state: directory
owner: "{{ venv_reuse_download_path_owner }}"
delegate_to: localhost
run_once: yes
when:
- venv_reuse_enable | bool
- name: Check if venv tgz is present on the deployment host
stat:
path: "{{ venv_reuse_download_path }}/{{ venv_destination_path | basename }}.tgz"
get_attributes: no
get_checksum: no
get_md5: no
get_mime: no
register: _src_venv_present
delegate_to: localhost
run_once: yes
when:
- venv_reuse_enable | bool
- name: Ensure that virtualenv is installed on the destination host
pip:
name: virtualenv
state: latest
extra_args: "{{ host_pip_install_args }}"
register: _install_host_pip_virtualenv
until: _install_host_pip_virtualenv | success
retries: 5
delay: 2