From d6bc63915fd0e8f858e62d307a9283cf37490973 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 27 Jan 2017 02:28:55 +0100 Subject: [PATCH] library/roles/python-env: Fix the recently broken pip deb package on ubuntu Trusty. --- python-env/defaults/main.yml | 9 +++++++++ python-env/files/pip-fixer.sh | 7 +++++++ python-env/tasks/main.yml | 38 ++++++++++++++++++++++++++++++++++- 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 python-env/files/pip-fixer.sh diff --git a/python-env/defaults/main.yml b/python-env/defaults/main.yml index 42388e5..590f3c1 100644 --- a/python-env/defaults/main.yml +++ b/python-env/defaults/main.yml @@ -2,5 +2,14 @@ py_env_install: False py_env_pkgs_state: installed py_env_site: False +py_env_trusty_workaround: True +py_env_get_pip_url: https://bootstrap.pypa.io/get-pip.py + py_env_basic_pkgs: - python-pip + +py_env_pip_fix_ssl_warnings: + - pyOpenSSL + - cryptography + - idna + - certifi diff --git a/python-env/files/pip-fixer.sh b/python-env/files/pip-fixer.sh new file mode 100644 index 0000000..c4ecda3 --- /dev/null +++ b/python-env/files/pip-fixer.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +GET_PIP=/usr/local/lib/get-pip.py + +chmod 755 $GET_PIP + +$GET_PIP diff --git a/python-env/tasks/main.yml b/python-env/tasks/main.yml index 62b5779..5cf6399 100644 --- a/python-env/tasks/main.yml +++ b/python-env/tasks/main.yml @@ -1,6 +1,5 @@ --- - block: - - name: Install python pip apt: name={{ item }} state={{ py_env_pkgs_state }} update_cache=yes cache_valid_time=600 with_items: '{{ py_env_basic_pkgs | default([]) }}' @@ -13,8 +12,45 @@ apt: name={{ item }} state={{ py_env_pkgs_state }} update_cache=yes cache_valid_time=600 with_items: '{{ py_pip_deps | default([]) }}' + - name: Fix the ssl warnings installing some ssl libraries + pip: name={{ item }} + with_items: '{{ py_env_pip_fix_ssl_warnings | default ([]) }}' + when: + - not py_env_trusty_workaround + - is_trusty + + - name: Install a list of pip packages + pip: name={{ item }} + with_items: '{{ py_env_pip_pkgs | default ([]) }}' + when: + - not py_env_trusty_workaround + - is_trusty + + when: py_env_install + tags: [ "python", "py_env" ] + +- block: + - name: Install the get-pip.py pip downloader + get_url: url={{ py_env_get_pip_url }} dest=/usr/local/lib/get-pip.py + + - name: Install a script that fixes the broken trusty pip package + copy: src=pip-fixer.sh dest=/usr/local/bin/python-pip-fixer mode=0755 owner=root group=root + register: python_pip_fixer + + - name: Fix the trusty pip installation + shell: /usr/local/bin/python-pip-fixer + when: ( python_pip_fixer | changed ) + + - name: Fix the ssl warnings installing some ssl libraries + pip: name={{ item }} + with_items: '{{ py_env_pip_fix_ssl_warnings | default ([]) }}' + - name: Install a list of pip packages pip: name={{ item }} with_items: '{{ py_env_pip_pkgs | default ([]) }}' + when: + - py_env_trusty_workaround + - py_env_install + - is_trusty tags: [ "python", "py_env" ]