From 52a988e55e1d80e6148fe2947f5803ed83f2aacd Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Mon, 19 Dec 2022 15:44:07 +0100 Subject: [PATCH] Set the minor version at runtime. --- defaults/main.yml | 5 +++-- meta/main.yml | 18 ++++++++---------- tasks/py3_deb.yml | 12 ++++++++++++ 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 63af7cc..1556235 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,11 +1,12 @@ --- -py3_env_install: True +py3_env_install: true py3_env_major_version: 3 +# We calculate the minor number is some cases. py3_env_minor_version: 6 py3_env_version: '{{ py3_env_major_version }}.{{py3_env_minor_version }}' py3_env_pkgs_state: present py3_pip_pkgs_state: present -py3_env_site: False +py3_env_site: false py3_env_dpkg: [] # Ugly. Don't do that diff --git a/meta/main.yml b/meta/main.yml index b4d4fa9..ca213fa 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,25 +1,23 @@ galaxy_info: + description: Role that installs python3 and optionally its modules author: Andrea Dell'Amico - description: Systems Architect + role_name: python3_environment company: ISTI-CNR + license: EUPL 1.2+ + min_ansible_version: '2.8' 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: - name: Ubuntu versions: - trusty - bionic + - focal + - jammy - name: EL versions: - - 7 + - '7' + - '8' galaxy_tags: - python diff --git a/tasks/py3_deb.yml b/tasks/py3_deb.yml index f7ed779..3289376 100644 --- a/tasks/py3_deb.yml +++ b/tasks/py3_deb.yml @@ -8,6 +8,18 @@ - ansible_distribution_version is version_compare('18.04', '<') 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: - 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