94 lines
4.3 KiB
YAML
94 lines
4.3 KiB
YAML
---
|
|
- 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
|
|
|
|
- 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:
|
|
py3_env_minor_version: '8'
|
|
when:
|
|
- not py3_env_ppa_enabled
|
|
- 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:
|
|
- not py3_env_ppa_enabled
|
|
- ansible_distribution_version is version_compare('22.04', '==')
|
|
|
|
- name: Python minor version of Ubuntu 24.04
|
|
ansible.builtin.set_fact:
|
|
py3_env_minor_version: '12'
|
|
when:
|
|
- not py3_env_ppa_enabled
|
|
- ansible_distribution_version is version_compare('24.04', '==')
|
|
|
|
- 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
|
|
|
|
- name: Install the python3 additional deb packages
|
|
apt: name={{ py3_env_dpkg }} state={{ py3_env_pkgs_state }} update_cache=yes cache_valid_time=600
|
|
|
|
- name: Install python3-pip deb packages on Bionic or newer
|
|
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 }}'
|
|
state: absent
|
|
loop: '{{ py3_deb_info_to_remove }}'
|
|
|
|
- name: Install the correct pip3 version on Ubuntu < 18.04
|
|
shell: python{{ py3_env_version }} -m ensurepip && pip{{ py3_env_version }} install --upgrade pip setuptools wheel
|
|
when: ansible_distribution_version is version_compare('18.04', '<')
|
|
|
|
- name: Install a list of versioned pip3 packages on Ubuntu older than Bionic
|
|
pip: executable=pip{{ py3_env_version }} name={{ item.pkg }} version={{ item.version }} extra_args={{ item.extra_args | default('') }}
|
|
with_items: '{{ py3_env_versioned_pip_pkgs | default ([]) }}'
|
|
when: ansible_distribution_version is version_compare('18.04', '<')
|
|
tags: [ "python", "py3_env", "py3_env_pkgs", 'python3', 'py3_pkgs_versioned' ]
|
|
|
|
- name: Install a list of pip3 packages on Ubuntu older than Bionic
|
|
pip: executable=pip{{ py3_env_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' ]
|
|
|
|
- name: Ensure that we have the latest pip, setuptools and wheel versions
|
|
pip:
|
|
executable: 'pip{{ py3_env_major_version }}'
|
|
name: '{{ py3_env_pip_default_pkgs }}'
|
|
state: latest
|
|
|
|
- name: Install a list of binary pip3 packages in wheels format
|
|
pip: executable=pip{{ py3_env_major_version }} name={{ py3_env_wheel_pip_pkgs }} state={{ py3_pip_pkgs_state }}
|
|
tags: [ "python", "py3_env", "py3_env_pkgs", 'python3', 'py3_pkgs_wheels' ]
|
|
|
|
- name: Install a list of versioned pip3 packages on Ubuntu Bionic or newer
|
|
pip: executable=pip{{ py3_env_major_version }} name={{ item.pkg }} version={{ item.version }} extra_args={{ item.extra_args | default('') }}
|
|
with_items: '{{ py3_env_versioned_pip_pkgs | default ([]) }}'
|
|
when: ansible_distribution_version is version_compare('18.04', '>=')
|
|
tags: [ "python", "py3_env", "py3_env_pkgs", 'python3', 'py3_pkgs_versioned' ]
|
|
|
|
- name: Install a list of pip3 packages on Ubuntu Bionic or newer
|
|
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' ]
|