diff --git a/roles/ensure-pip/defaults/main.yaml b/roles/ensure-pip/defaults/main.yaml index 2d92a5e38..103e1ff96 100644 --- a/roles/ensure-pip/defaults/main.yaml +++ b/roles/ensure-pip/defaults/main.yaml @@ -1,5 +1,5 @@ ensure_pip_from_packages: True -ensure_pip_from_packages_with_python2: False +ensure_pip_from_packages_with_python2: '{{ (ansible_python.version.major == 2) | ternary(True, False) }}' ensure_pip_from_upstream_url: 'https://bootstrap.pypa.io/get-pip.py' ensure_pip_from_upstream: False ensure_pip_from_upstream_interpreters: diff --git a/roles/ensure-pip/tasks/Debian.yaml b/roles/ensure-pip/tasks/Debian.yaml index d70a07552..95b292a6f 100644 --- a/roles/ensure-pip/tasks/Debian.yaml +++ b/roles/ensure-pip/tasks/Debian.yaml @@ -12,5 +12,4 @@ - python-setuptools - python-pip become: yes - when: (ensure_pip_from_packages_with_python2) or - (ansible_python.version.major == 2) + when: ensure_pip_from_packages_with_python2 diff --git a/roles/ensure-pip/tasks/RedHat.yaml b/roles/ensure-pip/tasks/RedHat.yaml index cf976ce14..cffe44205 100644 --- a/roles/ensure-pip/tasks/RedHat.yaml +++ b/roles/ensure-pip/tasks/RedHat.yaml @@ -16,5 +16,4 @@ - python-virtualenv state: present become: yes - when: (ensure_pip_from_packages_with_python2) or - (ansible_python.version.major == 2) + when: ensure_pip_from_packages_with_python2 diff --git a/roles/ensure-pip/tasks/Suse.yaml b/roles/ensure-pip/tasks/Suse.yaml index 7dacfe319..8eb1109d8 100644 --- a/roles/ensure-pip/tasks/Suse.yaml +++ b/roles/ensure-pip/tasks/Suse.yaml @@ -7,5 +7,4 @@ package: name: python2-pip become: yes - when: - - ensure_pip_from_packages_with_python2 + when: ensure_pip_from_packages_with_python2 diff --git a/roles/ensure-pip/tasks/main.yaml b/roles/ensure-pip/tasks/main.yaml index 74df1d9c0..8c572d6cd 100644 --- a/roles/ensure-pip/tasks/main.yaml +++ b/roles/ensure-pip/tasks/main.yaml @@ -37,6 +37,9 @@ - ensure_pip_from_packages - pip_preinstalled.rc != 0 +- name: Include workarounds + include: workarounds.yaml + - name: Install pip from source include: source.yaml when: diff --git a/roles/ensure-pip/tasks/workarounds.yaml b/roles/ensure-pip/tasks/workarounds.yaml new file mode 100644 index 000000000..d06285bf3 --- /dev/null +++ b/roles/ensure-pip/tasks/workarounds.yaml @@ -0,0 +1,18 @@ +# +# This file contains workaround tasks for specific issues +# + +# Somehow on SuSE 15 the dependencies are such that python2-pip can be +# installed, but setuptools is not. This breaks Ansible's pip: which +# does a direct import of pkg_resources and thus has a hard-dependency +# on setuptools. This doesn't appear to happen for python3. Thus we +# ensure this is installed, even if we skipped install phase because +# pip looked like it was installed already. +- name: Ensure setuptools + package: + name: python-setuptools + become: yes + when: + - ansible_python.version.major == 2 + - ansible_os_family == 'Suse' + - ansible_distribution_major_version == '15'