Deprecation warnings with ansible-core 2.20.2

I installed ansible-core 2.20.2 yesterday (I’ve been using the version provided with EL9 until now, but needed some uplevel collections to be installed). I’m getting deprecation warnings for ansible.module_utils.common._collections_compat and various ansible.module_utils._*, including _text but I get them without using any external collections that I see. I can’t see anything wrong with the installation of ansible-core which was done using python3-pip-3.13 to ~/.local/bin/ansible. A trivial example using just assert is:

- hosts: localhost
  gather_facts: false
  tasks:
  - assert:
      that: true | bool

which gives this result (but only if | bool is included):

[steve@trillian IaC]$ ansible-playbook tmp.yml

PLAY [localhost] **************************************************************************************************************************************************************************

TASK [assert] *****************************************************************************************************************************************************************************
Friday 06 February 2026  18:20:42 +0000 (0:00:00.030)       0:00:00.030 ******* 
[WARNING]: Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.
[DEPRECATION WARNING]: The `ansible.module_utils.common._collections_compat` module is deprecated. This feature will be removed from ansible-core version 2.24. Use `collections.abc` from the Python standard library instead.
ok: [localhost] => 
    changed: false
    msg: All assertions passed

PLAY RECAP ********************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   


TASKS RECAP *******************************************************************************************************************************************************************************
Friday 06 February 2026  18:20:43 +0000 (0:00:00.067)       0:00:00.098 ******* 
=============================================================================== 
assert ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.07s
[steve@trillian IaC]$

Ansible config:

[steve@trillian IaC]$ ansible --version
ansible [core 2.20.2]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/steve/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/steve/.local/lib/python3.13/site-packages/ansible
  ansible collection location = /home/steve/.ansible/collections:/usr/local/share/ansible/collections:/usr/share/ansible/collections
  executable location = /home/steve/.local/bin/ansible
  python version = 3.13.11 (main, Dec  5 2025, 00:00:00) [GCC 11.5.0 20240719 (Red Hat 11.5.0-11)] (/usr/bin/python3.13)
  jinja version = 3.1.6
  pyyaml version = 6.0.3 (with libyaml v0.2.5)
[steve@trillian IaC]$ 

O/S

[steve@trillian IaC]$ cat /etc/redhat-release 
AlmaLinux release 9.7 (Moss Jungle Cat)
[steve@trillian IaC]$

Installed collections:

[steve@trillian IaC]$ ansible-galaxy collection list

# /usr/local/share/ansible/collections/ansible_collections
Collection               Version
------------------------ -------
ansible.netcommon        8.4.0  
ansible.posix            2.1.0  
ansible.utils            6.0.1  
awx.awx                  24.6.1 
chocolatey.chocolatey    1.5.3  
community.crypto         3.1.0  
community.dns            3.5.1  
community.docker         5.0.5  
community.general        12.3.0 
community.libvirt        2.0.0  
community.okd            5.0.0  
containers.podman        1.19.0 
infra.aap_utilities      2.8.0  
infra.leapp              1.6.1  
kubernetes.core          5.0.0  
oxlorg.opnsense          25.7.8 
redhat.openshift         4.0.1  

# /usr/share/ansible/collections/ansible_collections
Collection               Version
------------------------ -------
redhat.rhel_mgmt         1.1.0  
redhat.rhel_system_roles 1.108.6
[steve@trillian IaC]$ 

I don’t get this with a pristine ansible-core 2.20.2 installation, so I guess this is related to at least one of your installed collections.

You could use the Ansible Configuration Settings — Ansible Community Documentation setting to figure out what exactly is causing this, for example by running ANSIBLE_DISPLAY_TRACEBACK=deprecated ansible-playbook tmp.yml. That should hopefully show where the deprecation comes from.

Thanks @felixfontein: it’s ansible.utils

  File "/usr/local/share/ansible/collections/ansible_collections/ansible/utils/plugins/module_utils/common/utils.py", line 13, in <module>
    from ansible.module_utils.common._collections_compat import Mapping
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1023, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/home/steve/.local/lib/python3.13/site-packages/ansible/module_utils/common/_collections_compat.py", line 32, in <module>
    _warnings.deprecate(
Message: The `ansible.module_utils.common._collections_compat` module is deprecated.

I have 6.0.1 from December

[steve@trillian IaC]$ tail -n14 /usr/local/share/ansible/collections/ansible_collections/ansible/utils/changelogs/changelog.yaml 
  6.0.1:
    changes:
      bugfixes:
        - Add a cleanup step that removes empty {} and [] values from lists in keep_keys_from_dict_n_list()
      doc_changes:
        - Fix the description of the reduce_on_network filter.
        - Fix the module name in ipmath filter.
    fragments:
      - fix_data_tagging.yaml
      - fix_description.yaml
      - fix_keep_keys_list_retention.yaml
      - fix_module_name.yaml
      - fix_sanity.yaml
    release_date: "2025-12-31"
[steve@trillian IaC]$ 

A related issue: remove_keys uses deprecated methods · Issue #421 · ansible-collections/ansible.utils · GitHub

(Maybe you have some config, inventory, … somewhere that uses a filter from the collection, and thus triggers the deprecation warning? I do have that collection installed as well, but I don’t get the deprecation with your playbook.)

There’s also a PR which fixes these deprecations: Fix several deprecations by olaf-mandel · Pull Request #423 · ansible-collections/ansible.utils · GitHub