diff --git a/python-env/defaults/main.yml b/python-env/defaults/main.yml index 42388e5d..590f3c10 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 00000000..c4ecda36 --- /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 62b57791..5cf63996 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" ]