
* EL9 has python3.9 as system Python * EL10 has bumped up this to python3.12 * Added a short novel for future archaeologists. Change-Id: Ie9ee25207cee5b5aed773c2dc89a05bf6243069e
98 lines
3.4 KiB
YAML
98 lines
3.4 KiB
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 python using system packages
|
|
when:
|
|
- python_version is defined
|
|
- not python_use_pyenv
|
|
- not python_use_stow
|
|
block:
|
|
- name: Install specified version of python interpreter and development files (DEB)
|
|
when:
|
|
- ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
|
|
package:
|
|
name:
|
|
- 'python{{ python_version }}-dev'
|
|
state: present
|
|
become: yes
|
|
|
|
# Ubuntu splits out the venv package, which is really the only
|
|
# sane way to use a non-default-but-packaged version of python on
|
|
# your system (i.e. via virtual environments setup with python<v>
|
|
# -m venv). Pull it in by default for python3.
|
|
- name: Pull in venv package
|
|
when:
|
|
- ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
|
|
- python_version is version('3', '>')
|
|
package:
|
|
name:
|
|
- 'python{{ python_version }}-venv'
|
|
state: present
|
|
become: yes
|
|
|
|
- name: Install specified version of python interpreter and development files (RPM)
|
|
# NOTE(jan.gutter): this section has many pitfalls, and lacks test
|
|
# coverage. Rather than rewrite the logic to be more pleasing, and risk
|
|
# changing the behavior for folks who depend on edge cases, it has been
|
|
# preferrable to amend this with special cases, for the time being.
|
|
#
|
|
# RPM distros have diverged in behavior: packages and aliases are not
|
|
# consistent. The following example illustrates some known behavior for
|
|
# python_version "3.12"
|
|
#
|
|
# Fedora/EL9/EL10 (manually tested):
|
|
# working:
|
|
# - python312
|
|
# - python3.12
|
|
# - python3.12-devel
|
|
# not working:
|
|
# - python312-devel
|
|
#
|
|
# OpenSuSE (inferred from rpmfind.net):
|
|
# working:
|
|
# - python312
|
|
# - python312-devel
|
|
# not working:
|
|
# - python3.12
|
|
# - python3.12-devel
|
|
when:
|
|
- ansible_distribution == 'CentOS' or ansible_distribution == 'RedHat'
|
|
block:
|
|
- name: Set default RPM package name
|
|
# NOTE(jan.gutter): this is likely faulty - but, without testing,
|
|
# touching it would taunt Hyrum's law. EL9/EL10 paths override the
|
|
# exception below this task for system python versions.
|
|
set_fact:
|
|
rpm_python_pkg_name: python{{ python_version | replace('.', '') }}-devel
|
|
- name: Set RPM package name for CentOS/RHEL 9/10
|
|
# Special case when the default system python is being used.
|
|
set_fact:
|
|
rpm_python_pkg_name: python3-devel
|
|
when: >-
|
|
(ansible_distribution_major_version == '9' and
|
|
python_version|string == '3.9')
|
|
or
|
|
(ansible_distribution_major_version == '10' and
|
|
python_version|string == '3.12')
|
|
- name: Install RPM package
|
|
package:
|
|
name: "{{ rpm_python_pkg_name }}"
|
|
state: present
|
|
become: yes
|
|
|
|
- name: Install python using pyenv
|
|
when:
|
|
- python_use_pyenv
|
|
include_tasks: pyenv.yaml
|
|
|
|
- name: Activate python using stow
|
|
when:
|
|
- python_version is defined
|
|
- python_use_stow
|
|
include_tasks: stow.yaml
|