From c710ede34bd5b1f752b3bb5cd35325adb0535aba Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Wed, 24 Oct 2018 19:09:39 +0200 Subject: [PATCH] Role to install python 3 > 3.4 on Ubuntu 14.04. --- python3-env/defaults/main.yml | 14 ++++++++++++++ python3-env/tasks/main.yml | 23 +++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 python3-env/defaults/main.yml create mode 100644 python3-env/tasks/main.yml diff --git a/python3-env/defaults/main.yml b/python3-env/defaults/main.yml new file mode 100644 index 00000000..c8907179 --- /dev/null +++ b/python3-env/defaults/main.yml @@ -0,0 +1,14 @@ +--- +py3_env_install: False +py3_ppa: 'ppa:deadsnakes/ppa' +py3_env_version: 3.6 +py3_env_pkgs_state: present +py3_env_site: False + +py3_env_basic_pkgs: + - python-pip + +py3_env_dpkg: + - 'python{{ py3_env_version }}' + - 'python{{ py3_env_version }}-venv' + - 'python{{ py3_env_version }}-dev' diff --git a/python3-env/tasks/main.yml b/python3-env/tasks/main.yml new file mode 100644 index 00000000..8d7b4b28 --- /dev/null +++ b/python3-env/tasks/main.yml @@ -0,0 +1,23 @@ +--- +- block: + - name: Install the python 3 ppa repository + apt_repository: repo={{ py3_ppa }} update_cache=yes state=present + + - name: Install the python3 deb packages + apt: name={{ py3_env_dpkg }} state={{ py_env_pkgs_state }} update_cache=yes cache_valid_time=600 + + - name: Install the correct pip3 version + shell: python{{ py3_env_version }} -m ensurepip && pip{{ py3_env_version }} install --upgrade pip setuptools wheel + + - name: Install a list of pip packages + pip: executable=pip{{ py3_env_version }} name={{ py3_env_pip_pkgs }} state=latest + + - name: Install a list of versioned pip packages + pip: executable=pip{{ py3_env_version }} name={{ item.pkg }} version={{ item.version }} + with_items: '{{ py3_env_versioned_pip_pkgs | default ([]) }}' + + when: + - py3_env_install + - is_trusty + tags: [ "python", "py3_env", "py3_env_pkgs", 'python3' ] +