Find source of Deprecation warning

Hello,
I am running ansible 2.21 on a Debian 13. Whenever I run Ansible, I get a deprecation warning. None of my playbooks use that deprecated function and the warning shows up no matter what arguments I give it (even no arguments or --version or --help). I have updated ansible’s own collections but the message persists.

Here is the message:

[WARNING]: Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.
[DEPRECATION WARNING]: Importing 'to_text' from 'ansible.module_utils._text' is deprecated. This feature will be removed from ansible-core version 2.24. Use ansible.module_utils.common.text.converters instead.

Here’s what --version has to say:

ansible [core 2.21.2]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/myuser/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/myuser/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.13.5 (main, Jul 15 2026, 20:25:40) [GCC 14.2.0] (/usr/bin/python3)
  jinja version = 3.1.6
  pyyaml version = 6.0.2 (with libyaml v0.2.5)

And here is the result of ansible-galaxy collection list:


# /home/myuser/.ansible/collections/ansible_collections
Collection                               Version
---------------------------------------- -------
ansible.netcommon                        8.6.0  
ansible.posix                            2.2.2  
ansible.utils                            6.0.3  
ansible.windows                          3.7.0  
community.general                        13.2.0 

# /usr/lib/python3/dist-packages/ansible/_internal/ansible_collections
Collection                               Version
---------------------------------------- -------
ansible._protomatter                     *      

# /usr/lib/python3/dist-packages/ansible_collections
Collection                               Version
---------------------------------------- -------
amazon.aws                               11.4.0 
ansible.mysql                            5.1.0  
ansible.netcommon                        8.6.0  
ansible.posix                            2.2.2  
ansible.utils                            6.0.3  
ansible.windows                          3.7.0  
arista.eos                               12.1.2 
azure.azcollection                       3.20.0 
check_point.mgmt                         6.9.0  
chocolatey.chocolatey                    1.6.0  
cisco.aci                                2.13.0 
cisco.intersight                         2.20.0 
cisco.ios                                11.4.2 
cisco.iosxr                              12.3.2 
cisco.meraki                             2.24.1 
cisco.mso                                2.13.0 
cisco.nxos                               11.2.0 
cisco.ucs                                1.16.0 
cloudscale_ch.cloud                      2.5.3  
community.aws                            11.1.0 
community.ciscosmb                       1.0.12 
community.clickhouse                     2.3.0  
community.crypto                         3.3.0  
community.dns                            4.0.2  
community.docker                         5.2.1  
community.general                        13.2.0 
community.grafana                        2.3.0  
community.hashi_vault                    7.1.0  
community.hrobot                         2.7.2  
community.library_inventory_filtering_v1 1.1.5  
community.libvirt                        2.3.0  
community.mongodb                        1.8.0  
community.mysql                          5.0.2  
community.okd                            5.0.0  
community.postgresql                     4.2.0  
community.proxmox                        2.0.0  
community.proxysql                       1.8.0  
community.rabbitmq                       1.7.0  
community.routeros                       3.21.0 
community.sap_libs                       1.7.0  
community.sops                           2.4.0  
community.vmware                         6.2.1  
community.windows                        3.3.0  
community.zabbix                         4.2.0  
containers.podman                        1.20.2 
cyberark.conjur                          1.3.12 
cyberark.pas                             1.0.39 
dellemc.enterprise_sonic                 4.1.0  
dellemc.openmanage                       10.0.3 
dellemc.powerflex                        3.1.0  
dellemc.unity                            2.1.0  
f5networks.f5_modules                    1.42.0 
fortinet.fortimanager                    2.14.0 
fortinet.fortios                         2.5.1  
google.cloud                             1.13.0 
grafana.grafana                          6.1.0  
graphiant.naas                           26.6.0 
hetzner.hcloud                           6.10.0 
hitachivantara.vspone_block              4.8.2  
hitachivantara.vspone_object             1.2.0  
ibm.storage_virtualize                   3.3.0  
ieisystem.inmanage                       4.0.0  
infinidat.infinibox                      1.8.1  
infoblox.nios_modules                    1.9.0  
inspur.ispim                             2.2.4  
kaytus.ksmanage                          4.0.0  
kubernetes.core                          6.5.0  
kubevirt.core                            2.3.0  
lowlydba.sqlserver                       2.8.1  
microsoft.ad                             1.12.0 
microsoft.iis                            1.2.1  
netapp.cloudmanager                      21.24.0
netapp.ontap                             23.5.0 
netapp.storagegrid                       21.16.0
netapp_eseries.santricity                2.0.1  
netbox.netbox                            3.23.0 
ngine_io.cloudstack                      3.0.0  
openstack.cloud                          2.6.0  
ovirt.ovirt                              3.2.2  
pcg.alpaca_operator                      2.2.0  
purestorage.flasharray                   1.43.0 
purestorage.flashblade                   1.26.0 
ravendb.ravendb                          1.0.4  
splunk.es                                6.0.1  
telekom_mms.icinga_director              2.5.1  
theforeman.foreman                       5.11.0 
vmware.vmware                            2.9.0  
vmware.vmware_rest                       4.11.0 
vultr.cloud                              1.14.1 
vyos.vyos                                6.0.0  
wti.remote                               1.0.11 

Where can I find out where the deprecation is coming from and fix it?
Thank you

You can use Ansible Configuration Settings — Ansible Core Documentation and set the option to deprecated, then you will get a stack trace and can see which plugin caused the deprecation.

Usually looking at the task which triggers the deprecation also provides that information. It’s likely some collection that hasn’t fixed these imports yet.

Thanks, indeed I get more details like that.

Here’s what the trace says:

Traceback (most recent call last):
  File "/usr/local/bin/ansible", line 36, in <module>
    from ansible.module_utils._text import to_text
  File "/usr/lib/python3/dist-packages/ansible/module_utils/_text.py", line 30, in __getattr__
    _warnings.deprecate(
Message: Importing 'to_text' from 'ansible.module_utils._text' is deprecated.

I can indeed see that the deprecated import is present in the /usr/local/bin/ansible file, but I’m a bit confused because this is part of Ansible itself and I already have the latest version available on apt, i.e 2.21.2-1ppa~noble

You are mixing ansible versions, your ansible executable is a much older version than the module_utils, Python 2 support was removed long ago, so the script you are showing is not the one shipped with 2.21.

Yeah, this looks like it’s from a very old ansible-core version. Likely even pre-ansible-core, since even Ansible 2.9 didn’t support Python 2.6 on the controller.

If this file comes from a system package / PPA, you should be able to use dpkg -S /usr/local/bin/ansible to figure out which package it comes from.