zuul-jobs/roles/ensure-python/tasks/main.yaml
Monty Taylor e71d0d2607 Add support for installing python with pyenv
In order to install particular python versions on distros that
don't otherwise have them, add an option for installing via
pyenv.

The packages to be installed to allow for Python to be built were
tested on the official Docker containers so they should provide
a fair amount of coverage from a minimal environment.

Co-Authored-By: Mohammed Naser <mnaser@vexxhost.com>
Change-Id: Ic3312458b499a4b743895fa5829bb25155f77654
2020-03-17 17:32:49 -04:00

24 lines
674 B
YAML

- name: Validate python_version value
assert:
that:
- (python_version|string).split(".") | length == 2
- (python_version|string).split(".")[0]
- (python_version|string).split(".")[1]
when: python_version is defined
- name: Install specified version of python interpreter and development files
when:
- python_version is defined
- ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- not python_use_pyenv
package:
name: python{{ python_version }}-dev
state: present
become: yes
- name: Install python using pyenv
when:
- python_version is defined
- python_use_pyenv
include_tasks: pyenv.yaml