Skip to content

fix: ansible-core v2.24 errors - #2541

Merged
joelkeener merged 1 commit into
develfrom
INFRAANO-2068-support-2.24
Oct 29, 2026
Merged

joelkeener merged 1 commit into
develfrom
INFRAANO-2068-support-2.24

Conversation

@joelkeener

@joelkeener joelkeener commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Updated todo list

Summary

Removes the ansible-core APIs that are deprecated in 2.21 and removed in 2.24 (ansible.module_utils.six, ansible.module_utils._text and ansible.module_utils.common._collections_compat) from the collection. This clears the 2.21 deprecation warnings and keeps the collection working on ansible-core 2.24. Ticket: INFRAANO-2068.

Changes

Plugins (37 files: 31 modules, 4 module_utils, 1 action plugin, 1 lookup plugin)

  • six.string_types is replaced with str.
    • This covers bigip_command, bigip_device_auth, bigip_device_httpd, bigip_device_info, bigip_network_globals, bigip_snmp, bigip_user, bigiq_application_https_offload, bigiq_application_https_waf and bigiq_device_info.
  • six.iteritems(x) is replaced with x.items().
    • This covers module_utils/common.py, module_utils/compare.py and 23 modules, for example bigip_pool, bigip_virtual_server, bigip_device_info and bigiq_device_info.
  • six.moves.urllib.{error,parse} is replaced with stdlib urllib.error and urllib.parse.
    • This covers module_utils/icontrol.py, module_utils/teem.py, modules/bigip_software_install.py and action/bigip_imish_config.py.
  • ansible.module_utils._text is replaced with ansible.module_utils.common.text.converters.
    • This covers modules/bigip_user.py, lookup/license_hopper.py and action/bigip_imish_config.py.

Tests (7 files under tests/unit/)

  • modules/conftest.py now uses collections.abc.MutableMapping, str and converters.to_bytes.
  • mock/procenv.py, mock/yaml_helper.py and modules/network/f5/test_bigip_irule.py: PY3 branches removed, keeping the Python 3 path.
  • mock/vault_helper.py and modules/utils.py: _text import switched to converters.
  • modules/network/f5/test_bigip_device_info.py: iteritems replaced with .items().

Changelog

  • Added changelogs/fragments/fix-ansible-core-2.24-deprecated-imports.yaml as a minor_changes entry.

No behavior changes are intended. Every replacement is plain Python 3 and works on ansible-core 2.16 (the minimum in meta/runtime.yml) and on the Python 3.8 target.

Testing

  • A search over plugins and tests finds no remaining uses of iteritems, string_types, PY3, module_utils.six, module_utils._text or _collections_compat.
  • The unit suite was run on ansible-core 2.21.3 and Python 3.14, comparing HEAD against the working tree. Both runs gave 451 failed and 612 passed, with an identical set of failing tests.
  • The 451 failures happen on HEAD too and look environment-related (No serialization profile was specified from the test mocks). This MR doesn't introduce or fix them.
  • flake8 (max line length 160) reports no new warnings, and there is no trailing whitespace in the changed files.
  • The CI matrix on ansible-core 2.16 and 2.21 and the Red Hat certification run have not been run yet.

Checklist

  • CI unit tests pass on ansible-core 2.16 and 2.21
  • Sanity tests and Red Hat certification pass
  • Changelog fragment added
  • No security concerns identified

Ref:INFRAANO-2068

Ref:INFRAANO-2068

@crosbygw crosbygw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary: INFRAANO-2068-support-2.24 vs devel

This is a mechanical cleanup removing deprecated ansible.module_utils.six, ._text, and .common._collections_compat imports ahead of ansible-core 2.24, replacing them with stdlib equivalents (urllib.*, direct str/.items() usage) and ansible.module_utils.common.text.converters for to_text/to_bytes/to_native.

No blocking issues. All substitutions were verified behaviorally equivalent in Python 3, and replacement imports were confirmed to work under the installed ansible-core version.

One pre-existing bug noted (not introduced by this diff, informational only):
bigip_virtual_server.py:1678 — profile_types property calls .items() on self.profiles, which is actually a list, not a dict. This would raise AttributeError if ever called. The original code had the same bug (six.iteritems() is just a thin wrapper over .items()), so this change is a faithful mechanical translation, not a regression. The property also appears to be dead code (unreferenced elsewhere), which is likely why it's gone unnoticed. Worth a follow-up cleanup ticket, but not something to block this PR on.

Everything else — import correctness, pattern consistency with existing codebase, Python 3-only assumption for removing PY3/version checks in test mocks, and the changelog fragment — checked out fine. This is safe to proceed with as-is.

@joelkeener
joelkeener merged commit 299bae3 into devel Oct 29, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants