Repository navigation
fix: ansible-core v2.24 errors - #2541
Conversation
Ref:INFRAANO-2068
crosbygw
left a comment
There was a problem hiding this comment.
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.
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._textandansible.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_typesis replaced withstr.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_wafandbigiq_device_info.six.iteritems(x)is replaced withx.items().module_utils/common.py,module_utils/compare.pyand 23 modules, for examplebigip_pool,bigip_virtual_server,bigip_device_infoandbigiq_device_info.six.moves.urllib.{error,parse}is replaced with stdliburllib.errorandurllib.parse.module_utils/icontrol.py,module_utils/teem.py,modules/bigip_software_install.pyandaction/bigip_imish_config.py.ansible.module_utils._textis replaced withansible.module_utils.common.text.converters.modules/bigip_user.py,lookup/license_hopper.pyandaction/bigip_imish_config.py.Tests (7 files under
tests/unit/)modules/conftest.pynow usescollections.abc.MutableMapping,strandconverters.to_bytes.mock/procenv.py,mock/yaml_helper.pyandmodules/network/f5/test_bigip_irule.py:PY3branches removed, keeping the Python 3 path.mock/vault_helper.pyandmodules/utils.py:_textimport switched toconverters.modules/network/f5/test_bigip_device_info.py:iteritemsreplaced with.items().Changelog
changelogs/fragments/fix-ansible-core-2.24-deprecated-imports.yamlas aminor_changesentry.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
pluginsandtestsfinds no remaining uses ofiteritems,string_types,PY3,module_utils.six,module_utils._textor_collections_compat.HEADagainst the working tree. Both runs gave 451 failed and 612 passed, with an identical set of failing tests.HEADtoo and look environment-related (No serialization profile was specifiedfrom the test mocks). This MR doesn't introduce or fix them.Checklist
Ref:INFRAANO-2068