From 83012be82a8c5e6a38949561b94e0eb6aaa02e98 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Wed, 25 Jul 2018 12:23:10 +0200 Subject: [PATCH] Add a role that fixes the Ubuntu Trusty python distribution. --- ubuntu-python-setup/defaults/main.yml | 22 +++++++++++++++++ ubuntu-python-setup/files/pip-fixer.sh | 7 ++++++ ubuntu-python-setup/tasks/main.yml | 33 ++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 ubuntu-python-setup/defaults/main.yml create mode 100644 ubuntu-python-setup/files/pip-fixer.sh create mode 100644 ubuntu-python-setup/tasks/main.yml diff --git a/ubuntu-python-setup/defaults/main.yml b/ubuntu-python-setup/defaults/main.yml new file mode 100644 index 00000000..d44530fa --- /dev/null +++ b/ubuntu-python-setup/defaults/main.yml @@ -0,0 +1,22 @@ +--- +python_pkgs_state: present +python_trusty_workaround: True +python_get_pip_url: https://bootstrap.pypa.io/get-pip.py + +python_basic_pkgs: + - python-pip + +python_pip_dev_packages: + - libpython-dev + - libssl-dev + - libffi-dev + +python_pip_fix_ssl_warnings: + - pyOpenSSL + - cryptography + - idna + - certifi + - ndg-httpsclient + - urllib3 + - pyasn1 + diff --git a/ubuntu-python-setup/files/pip-fixer.sh b/ubuntu-python-setup/files/pip-fixer.sh new file mode 100644 index 00000000..c4ecda36 --- /dev/null +++ b/ubuntu-python-setup/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/ubuntu-python-setup/tasks/main.yml b/ubuntu-python-setup/tasks/main.yml new file mode 100644 index 00000000..037d1480 --- /dev/null +++ b/ubuntu-python-setup/tasks/main.yml @@ -0,0 +1,33 @@ +--- +- block: + - name: Install the get-pip.py pip downloader + get_url: url={{ python_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 is changed + + - name: Install the python dev headers and other dev requirements + apt: pkg={{ item }} state={{ python_pkgs_state }} update_cache=yes cache_valid_time=1800 + with_items: '{{ python_pip_dev_packages }}' + + - name: Install a specific version of tornado to avoid breaking dependencies + pip: name=tornado version=4.1 state=present + + - name: Install the latest six python package + pip: name=six state=present + + - name: Install setuptools version 33.1.1 + pip: name=setuptools version=33.1.1 state=present + + - name: Fix the ssl warnings installing some ssl libraries + pip: name={{ item }} state={{ python_pkgs_state }} + with_items: '{{ python_pip_fix_ssl_warnings | default ([]) }}' + register: python_pip_env_workaround + + when: is_trusty + tags: [ "python", 'py_env', 'ansible_setup' ]