Zabbix dynamic inventory not caching

We’ve been using the zabbix inventory plugin for a while to generate our ansible inventory, and it’s worked great. As we’ve grown, the process of starting a playbook has continued to take longer and longer as there’s been more servers to process (we’re at about 15 to 20 seconds now). So I’m trying to see what I can do to cut down that time. I first started with the API query, and cut as much excess there as I could. As I was debugging that, I found that the HTTP API calls actually take very little time, and it was the processing of the data from the API that’s taking the longest (compose, groups, and keyed_groups).

So now I’m trying to get caching to work. We’ve never used caching on the ansbile controller until now. I followed the directions at https://www.redhat.com/sysadmin/ansible-fact-cache-redis to get started and learn the basics, and I can confirm that the fact caching is working. I started by adding the cache* properties to the yml file configuring our zabbix inventory plugin (see community.zabbix.zabbix_inventory inventory – Zabbix Inventory Plugin — Ansible Documentation), but that didn’t seem to add anything to redis. Even though there’s notes about delegating the configs to the plugins, I also updated the same settings in the [inventory] section of our ansible.cfg, but that still doesn’t seem to make a difference.

At this point I’m not sure what else to try, and I’m hoping someone can point me in the right direction. Our ansible controller is running Rocky Linux 9. Here’s the output from ansible --version:

ansible [core 2.14.9]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.18 (main, Jan  4 2024, 00:00:00) [GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Here’s the applicable lines from the yml file configuring the zabbix inventory plugin:

plugin: community.zabbix.zabbix_inventory
cache: true
cache_plugin: 'community.general.redis'
cache_connection: 'localhost:6379:0'

And then the lines from ansible.cfg:

[defaults]
fact_caching=community.general.redis
fact_caching_connection=localhost:6379:0
fact_caching_timeout=86400
inventory=/etc/ansible/hosts,/etc/ansible/zabbix_inventory.yml

[inventory]
cache=true
cache_plugin=community.general.redis
cache_connection=localhost:6379:0

Also, when running ansible playbook with --list-hosts and -vvv, after the steps for processing the data from the API are complete, I see these two lines:

Parsed /etc/ansible/zabbix_inventory.yml inventory source with auto plugin
Redis connection: Redis<ConnectionPool<Connection<host=localhost,port=6379,db=0>>>

These lines show up whether or not I have the cache configs for inventory enabled, so I’m inclined to think that it’s an indication that the fact caching is working, but not necessarily the inventory caching.

So if anyone has ideas on how to proceed, that would be great. Thanks!