From 50375ac31c57ff1595d634f960532a892ddda75d Mon Sep 17 00:00:00 2001
From: Ian Wienand <iwienand@redhat.com>
Date: Thu, 23 Jul 2020 10:17:46 +1000
Subject: [PATCH] ensure-pip: Clarify situation with
 ensure_pip_from_packages_with_python2

With I450171aad5e31d2925239ab3d0641cd23f6815a2 we defaulted
ensure_pip_from_packages_with_python2 to True when Ansible was running
under Python 2.  Clarify in the documentation that it will be set in
this condition.  Also clarify that EPEL is required to install Python
2 pip packages on CentOS 7.

The RedHat.yaml started installing python2 packages unconditionally
when running under Python 2 with
I2ab11bb45b6b2a49d54db39195228ab40141185c.  This should have just
relied on ensure_pip_from_packages_with_python2 variable, update that.
Thus this will default to True when under Python 2, but will allow
people to turn off including the Python 2 packages if they know they
will not need them (e.g. they may run Ansible under Python 2, but only
ever use python3 in testing, and thus can avoid the epel dependency).

All of the distribution roles actually install the Python 3
pip/setuptools/wheel packages unconditionally when
ensure_pip_from_packages is set; they do *not* install it for the
``ansible_python_interpreter`` as implied by the documentation.

Change-Id: Ib948c8a156a0a96d610a310b6291781c5d3c7f96
---
 roles/ensure-pip/README.rst        | 19 +++++++++++--------
 roles/ensure-pip/tasks/RedHat.yaml |  3 +--
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/roles/ensure-pip/README.rst b/roles/ensure-pip/README.rst
index 6bb766e71..835613301 100644
--- a/roles/ensure-pip/README.rst
+++ b/roles/ensure-pip/README.rst
@@ -19,18 +19,21 @@ This role will also install ``wheel`` components sufficient to run
 .. zuul:rolevar:: ensure_pip_from_packages
    :default: True
 
-   Ensure the system packages for pip with the running
-   ``ansible_python_interpreter`` are installed.
+   Install the distribution packages for Python 3 pip, setuptools and
+   wheel on the system.
 
 .. zuul:rolevar:: ensure_pip_from_packages_with_python2
    :default: False
 
-   Also ensure Python 2 pip is available.  This is for backwards
-   compatability with platforms that have
-   ``ansible_python_interpreter`` as Python 3 but may run some jobs
-   that still require Python 2 libraries.  Note that this may bring in
-   the Python 2 interpreter environment, which may not be desirable or
-   even available on many platforms.
+   Install the distribution packages for Python 2 pip, setuptools and
+   wheel packages.  This defaults to ``True`` when Ansible is running
+   under Python 2.
+
+   CentOS 7 requies the ``epel`` repository if this flag is enabled
+   because ``python-pip`` packages come from there.
+
+   This may not be valid on distributions that have removed Python 2
+   support.
 
 .. zuul:rolevar:: ensure_pip_from_upstream
    :default: False
diff --git a/roles/ensure-pip/tasks/RedHat.yaml b/roles/ensure-pip/tasks/RedHat.yaml
index a9a6a405d..a80b3ed9a 100644
--- a/roles/ensure-pip/tasks/RedHat.yaml
+++ b/roles/ensure-pip/tasks/RedHat.yaml
@@ -17,5 +17,4 @@
     state: present
     enablerepo: epel
   become: yes
-  when: ensure_pip_from_packages_with_python2 or
-        ansible_python.version.major == 2
+  when: ensure_pip_from_packages_with_python2