ansible-role-python_venv_build/tasks/python_venv_preflight.yml
Jesse Pretorius ac5e5e9283 Simplify builds/installs by eliminating venv packaging
Python venvs are not particularly portable. To overcome this
problem we have a bunch of stuff implemented to fix them
after we unpack them. This ranges from relatively simple
things like re-implementing python in the venv and changing
the shebangs for everything in it, to more complex things
like having to package a venv per distro/architecture.

All of this can be eliminated by simplifying the mechanism
into just creating the venv on the target host, and installing
the python packages into it. To help speed up the build, we
can simply build wheels before hand and store them on a web
server somewhere.

This patch implements the changes to:

1. Do away with packaging the venv.
2. Keep it simple. We install into the venv, and that's that.
3. Add a toggle to rebuild the venv if you'd like to.
4. Use import_tasks with tags for each stage so that it's
   easy to skip a portion of what executes.

Change-Id: I708b5cf32e5cce6a18624d0b3be0cd4c828ad389
2018-09-01 16:38:42 +00:00

48 lines
1.7 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_install_destination_path has been provided
fail:
msg: |
The variable venv_install_destination_path is required and
has not been set.
when:
- venv_install_destination_path is not defined
- name: Collect the version of virtualenv
shell: |
virtualenv --version 2>/dev/null || echo 'none'
args:
executable: /bin/bash
changed_when: false
failed_when: false
register: _virtualenv_version
- name: Fail when required virtualenv version is not present
fail:
msg: >-
The required virtualenv version is not present.
The minimum version of 1.10 is required, but
{{ _virtualenv_version.stdout }} is installed.
when:
- ((_virtualenv_version.stdout | trim) == 'none') or
((_virtualenv_version.stdout | trim) is version_compare('1.10', '<'))
- name: Set extra virtualenv parameters
set_fact:
_venv_create_extra_options: >-
{{ ((_virtualenv_version.stdout | trim) is version_compare('14.0.0', '<')) | ternary('--never-download', '--no-download') }}
{{ ((_virtualenv_version.stdout | trim) is version_compare('1.7.0', '<')) | ternary('--no-site-packages', '') }}