Set the minor version at runtime.

This commit is contained in:
Andrea Dell'Amico 2022-12-19 15:44:07 +01:00
parent 2c1c78c6fe
commit 52a988e55e
Signed by: adellam
GPG Key ID: 147ABE6CEB9E20FF
3 changed files with 23 additions and 12 deletions

View File

@ -1,11 +1,12 @@
--- ---
py3_env_install: True py3_env_install: true
py3_env_major_version: 3 py3_env_major_version: 3
# We calculate the minor number is some cases.
py3_env_minor_version: 6 py3_env_minor_version: 6
py3_env_version: '{{ py3_env_major_version }}.{{py3_env_minor_version }}' py3_env_version: '{{ py3_env_major_version }}.{{py3_env_minor_version }}'
py3_env_pkgs_state: present py3_env_pkgs_state: present
py3_pip_pkgs_state: present py3_pip_pkgs_state: present
py3_env_site: False py3_env_site: false
py3_env_dpkg: [] py3_env_dpkg: []
# Ugly. Don't do that # Ugly. Don't do that

View File

@ -1,25 +1,23 @@
galaxy_info: galaxy_info:
description: Role that installs python3 and optionally its modules
author: Andrea Dell'Amico author: Andrea Dell'Amico
description: Systems Architect role_name: python3_environment
company: ISTI-CNR company: ISTI-CNR
license: EUPL 1.2+
min_ansible_version: '2.8'
issue_tracker_url: https://redmine-s2i2s.isti.cnr.it/projects/provisioning issue_tracker_url: https://redmine-s2i2s.isti.cnr.it/projects/provisioning
license: EUPL 1.2+
min_ansible_version: 2.8
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
platforms: platforms:
- name: Ubuntu - name: Ubuntu
versions: versions:
- trusty - trusty
- bionic - bionic
- focal
- jammy
- name: EL - name: EL
versions: versions:
- 7 - '7'
- '8'
galaxy_tags: galaxy_tags:
- python - python

View File

@ -8,6 +8,18 @@
- ansible_distribution_version is version_compare('18.04', '<') - ansible_distribution_version is version_compare('18.04', '<')
tags: [ "python", "py3_env", "py3_env_pkgs", 'python3' ] tags: [ "python", "py3_env", "py3_env_pkgs", 'python3' ]
- name: Find the appropriate python3 minor version
block:
- name: Python minor version of Ubuntu 20.04
ansible.builtin.set_fact:
py3_env_minor_version: '8'
when: ansible_distribution_version is version_compare('20.04', '==')
- name: Python minor version of Ubuntu 22.04
ansible.builtin.set_fact:
py3_env_minor_version: '10'
when: ansible_distribution_version is version_compare('22.04', '==')
- block: - block:
- name: Install the python3 mandatory deb packages - name: Install the python3 mandatory deb packages
apt: name={{ py3_env_mandatory_dpkg }} state={{ py3_env_pkgs_state }} update_cache=yes cache_valid_time=600 apt: name={{ py3_env_mandatory_dpkg }} state={{ py3_env_pkgs_state }} update_cache=yes cache_valid_time=600