From 68889c890c2b3cc8b3ebf65ccd27d5068cc7e8c8 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Wed, 1 Mar 2023 16:29:17 +0100 Subject: [PATCH] PPA in ubuntu > 14.04. --- defaults/main.yml | 1 + tasks/py3_deb.yml | 26 +++++++++++++++----------- vars/main.yml | 2 +- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 1556235..21b4916 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,5 +1,6 @@ --- py3_env_install: true +py3_env_ppa_enabled: false py3_env_major_version: 3 # We calculate the minor number is some cases. py3_env_minor_version: 6 diff --git a/tasks/py3_deb.yml b/tasks/py3_deb.yml index 3289376..a970cf2 100644 --- a/tasks/py3_deb.yml +++ b/tasks/py3_deb.yml @@ -1,14 +1,15 @@ --- -- block: +- name: Manage the python 3 ppa + tags: [python, py3_env, py3_env_pkgs, python3, py3_apt] + when: + - py3_env_install + - ansible_distribution_version is version_compare('18.04', '<') or py3_env_ppa_enabled + block: - name: Install the python 3 ppa repository apt_repository: repo={{ py3_ppa }} update_cache=yes state=present - when: - - py3_env_install - - ansible_distribution_version is version_compare('18.04', '<') - tags: [ "python", "py3_env", "py3_env_pkgs", 'python3' ] - - name: Find the appropriate python3 minor version + tags: ["python", "py3_env", "py3_env_pkgs", 'python3'] block: - name: Python minor version of Ubuntu 20.04 ansible.builtin.set_fact: @@ -20,7 +21,10 @@ py3_env_minor_version: '10' when: ansible_distribution_version is version_compare('22.04', '==') -- block: +- name: Manage the python packages + tags: [python, py3_env, py3_env_pkgs, python3, py3_apt] + when: py3_env_install + 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 @@ -31,6 +35,10 @@ apt: name=python3-pip state={{ py3_env_pkgs_state }} update_cache=yes cache_valid_time=600 when: ansible_distribution_version is version_compare('18.04', '>=') +- name: Manage the python pip packages + tags: [python, py3_env, py3_env_pkgs, python3, py3_pip] + when: py3_env_install + block: - name: Remove info of deb python packages so that they can be upgraded using pip file: dest: '{{ item }}' @@ -72,7 +80,3 @@ pip: executable=pip{{ py3_env_major_version }} name={{ py3_env_pip_pkgs }} state={{ py3_pip_pkgs_state }} when: ansible_distribution_version is version_compare('18.04', '>=') tags: [ "python", "py3_env", "py3_env_pkgs", 'python3', 'py3_pkgs_latest' ] - - when: py3_env_install - tags: [ "python", "py3_env", "py3_env_pkgs", 'python3' ] - diff --git a/vars/main.yml b/vars/main.yml index 3da4d70..6e578e3 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -16,4 +16,4 @@ py3_el_env_mandatory_pkg: - 'python{{ py3_env_major_version }}' - 'python{{ py3_env_major_version }}-pip' - 'python{{ py3_env_major_version }}-setuptools' - - "python{% if ansible_distribution_version is version_compare('18.04', '<=') %}{{ py3_el_env_version }}{% else %}{{ py3_env_major_version }}{% endif %}-virtualenv" + - "python{% if py3_env_ppa_enabled %}{{ py3_el_env_version }}{% else %}{{ py3_env_major_version }}{% endif %}-virtualenv"