From 9b4f9e9fd3cb929d213e1d43e5952efb1e6286c3 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Mon, 25 Oct 2021 08:41:51 -0500 Subject: [PATCH] Drop python2.6 support in module execution (#76106) --- changelogs/fragments/drop-target-2.6-support.yml | 2 ++ .../rst/porting_guides/porting_guide_core_2.13.rst | 14 +++++++------- lib/ansible/module_utils/basic.py | 14 +++----------- 3 files changed, 12 insertions(+), 18 deletions(-) create mode 100644 changelogs/fragments/drop-target-2.6-support.yml diff --git a/changelogs/fragments/drop-target-2.6-support.yml b/changelogs/fragments/drop-target-2.6-support.yml new file mode 100644 index 00000000000..3ff6cddbc0f --- /dev/null +++ b/changelogs/fragments/drop-target-2.6-support.yml @@ -0,0 +1,2 @@ +breaking_changes: +- Module Python Dependency - Drop support for Python 2.6 in module execution. diff --git a/docs/docsite/rst/porting_guides/porting_guide_core_2.13.rst b/docs/docsite/rst/porting_guides/porting_guide_core_2.13.rst index 5344719c2c5..39a286efa91 100644 --- a/docs/docsite/rst/porting_guides/porting_guide_core_2.13.rst +++ b/docs/docsite/rst/porting_guides/porting_guide_core_2.13.rst @@ -1,15 +1,15 @@ -.. _porting_2.13_guide: +.. _porting_2.13_guide_core: -************************** -Ansible 2.13 Porting Guide -************************** +******************************* +Ansible-core 2.13 Porting Guide +******************************* -This section discusses the behavioral changes between Ansible 2.12 and Ansible 2.13. +This section discusses the behavioral changes between ``ansible-core`` 2.12 and ``ansible-core`` 2.13. It is intended to assist in updating your playbooks, plugins and other parts of your Ansible infrastructure so they will work with this version of Ansible. -We suggest you read this page along with `Ansible Changelog for 2.13 `_ to understand what updates you may need to make. +We suggest you read this page along with `ansible-core Changelog for 2.13 `_ to understand what updates you may need to make. This document is part of a collection on porting. The complete list of porting guides can be found at :ref:`porting guides `. @@ -37,7 +37,7 @@ No notable changes Modules ======= -No notable changes +* Python 2.7 is a hard requirement for module execution in this release. Any code utilizing ``ansible.module_utils.basic`` will not function with a lower Python version. Modules removed diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index f243414295c..b55f9d433d6 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -248,24 +248,16 @@ PERMS_RE = re.compile(r'[^rwxXstugo]') # Used for determining if the system is running a new enough python version # and should only restrict on our documented minimum versions -_PY3_MIN = sys.version_info[:2] >= (3, 5) -_PY2_MIN = (2, 6) <= sys.version_info[:2] < (3,) -_PY26 = (2, 6) == sys.version_info[:2] +_PY3_MIN = sys.version_info >= (3, 5) +_PY2_MIN = (2, 7) <= sys.version_info < (3,) _PY_MIN = _PY3_MIN or _PY2_MIN if not _PY_MIN: print( '\n{"failed": true, ' - '"msg": "ansible-core requires a minimum of Python2 version 2.6 or Python3 version 3.5. Current version: %s"}' % ''.join(sys.version.splitlines()) + '"msg": "ansible-core requires a minimum of Python2 version 2.7 or Python3 version 3.5. Current version: %s"}' % ''.join(sys.version.splitlines()) ) sys.exit(1) -if _PY26: - deprecate( - 'ansible-core 2.13 will require Python 2.7 or newer on the target. ' - 'Current version: %s' % ''.join(sys.version.splitlines()), - version='2.13', - ) - # # Deprecated functions