Skip to content

Conversation

@rjeffman
Copy link
Member

@rjeffman rjeffman commented Nov 7, 2025

This patch removes all dependencies on the 'asible.module_util.six'
module and fixes deprecated imports as defined by the ansible-core
release version 2.20.

This changes render ansible-freeipa collection incompatible with
Python 2.

Changes include:

  • Remove six module imports from all modules and roles

    • Removed 'from ansible.module_utils import six' statements
    • Removed 'from ansible.module_utils.six.moves' imports
  • Replace and remove Python version checks (six.PY3 and six.PY2)

  • Replace unicode usage with to_text or str

  • Ensure text conversion routines imports are consistent and are
    imported from Ansible common.text.converters

  • Update standard library imports

    • Changed 'six.moves.urllib.parse' to 'urllib.parse'
    • Changed 'six.moves.configparser' to 'ConfigParser'
    • Import 'Mapping' from 'collections.abc'
  • Remove Python 2 specific code

Note that this change only addresses the deprecation issues
with ansible-core 2.20. For full migration from Python 2 the
minimum supported IPA version should be 4.9, that currently targets
Python 3.6.

Fixes #1399

Summary by Sourcery

Remove deprecated ansible.module_utils.six usage and Python 2 compatibility code to comply with ansible-core 2.20 deprecations.

Enhancements:

  • Remove all imports and usage of ansible.module_utils.six and eliminate Python 2 specific branches.
  • Replace unicode references with str or to_text and consolidate text conversion imports from ansible.module_utils.common.text.converters.
  • Update standard library imports to modern modules (urllib.parse, ConfigParser, collections.abc.Mapping).
  • Revise certificate tests to use regex matching for "not found" messages instead of hardcoded substrings.

@rjeffman rjeffman requested a review from t-woerner November 7, 2025 19:57
@rjeffman rjeffman added ansible An ansible-freeipa issue with some version of Ansible. DRAFT Version 2.0 labels Nov 7, 2025
@rjeffman rjeffman changed the title Remove ansible-core 2.20 deprecated imports @rjeffman Remove ansible-core 2.20 deprecated imports Nov 8, 2025
@rjeffman rjeffman force-pushed the python3_only_playground branch from d10b6cf to 6e89fcc Compare November 8, 2025 00:56
This commit removes all dependencies on the 'asible.module_util.six'
module and fixes deprecated imports as defined by the ansible-core
release version 2.20.

This changes render ansible-freeipa collection incompatible with
Python 2.

Changes include:

* Remove six module imports from all modules and roles
  - Removed 'from ansible.module_utils import six' statements
  - Removed 'from ansible.module_utils.six.moves' imports

* Replace and remove Python version checks (six.PY3 and six.PY2)

* Replace unicode usage with to_text or str

* Ensure text conversion routines imports are consistent and are
  imported from Ansible common.text.converters

* Update standard library imports
  - Changed 'six.moves.urllib.parse' to 'urllib.parse'
  - Changed 'six.moves.configparser' to 'ConfigParser'
  - Import 'Mapping' from 'collections.abc'

* Remove Python 2 specific code

Signed-off-by: Rafael Guterres Jeffman <[email protected]>
@rjeffman rjeffman force-pushed the python3_only_playground branch from 6e89fcc to e2baf9b Compare November 11, 2025 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ansible An ansible-freeipa issue with some version of Ansible. DRAFT Version 2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ansible 'six' is deprecated and will be removed in 2.24

1 participant