Files
zuul-jobs/roles/ensure-python/tasks/main.yaml
Szymon Datko ced6cd132f Add support for RPM packages
This commit extends the installation of Python interpreter
from system packages to also support RPM packages (assuming
the playbook is run in an environment with proper repositories).

Also the obsolete note about supporting only Debian distribution
is removed, as the `ensure-python` role already supports other
platforms (via pyenv and stow).

Change-Id: Id6ef8ec3537952348e0a7b233bd26b57613da327
2022-01-18 16:00:22 +01:00

42 lines
1.2 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
- name: Install specified version of python interpreter and development files (RPM)
when:
- ansible_distribution == 'CentOS' or ansible_distribution == 'RedHat'
package:
name: python{{ python_version | replace('.', '') }}-devel
state: present
become: yes
- name: Install python using pyenv
when:
- python_version is defined
- python_use_pyenv
include_tasks: pyenv.yaml
- name: Activate python using stow
when:
- python_version is defined
- python_use_stow
include_tasks: stow.yaml