How to access inventory from custom action plugin v2

Hi,

How does one get access to the inventory from a custom action plugin?

I’m able to do something like this to access host vars: task_vars[“hostvars”][“my_host”][“ansible_host”] but I need to be able to iterate all hosts in the inventory.

Thanks,
James.

hostvars always has all hosts present in inventory, you can also look at groups[‘all’] to get the full list.