tobiko/roles/tobiko-ensure-python3/tasks/python3.yaml

50 lines
1.2 KiB
YAML

---
- name: "include platform variables"
include_tasks: platform.yaml
when:
- python_platform is not defined
- name: "validate Python version: {{ python_version }}"
assert:
that:
- (python_version | string).split(".") | length >= 1
- (python_version | string).split(".") | length <= 2
- (python_version | string).split(".")[0] == '3'
- include_tasks: constraints.yaml
- include_tasks: install.yaml
vars:
python_command: '{{ python3_command }}'
- name: "set python3_executable fact"
set_fact:
python3_executable: '{{ python_info[python3_command].executable }}'
- block:
- include_tasks: install.yaml
when: python_command not in python_info
- name: "set python_executable fact"
set_fact:
python_executable: '{{ python_info[python_command].executable }}'
rescue:
- name: "try setting python alternative to '{{ python_alternative }}'"
become: '{{ test_become | bool }}'
command: "alternatives --set python '{{ python_alternative }}'"
ignore_errors: yes
when: 'python_alternative is defined'
- include_tasks: install.yaml
- name: "set python_executable fact"
set_fact:
python_executable: '{{ python_info[python_command].executable }}'