# How to access inventory from custom action plugin v2

**URL:** <https://forum.ansible.com/t/how-to-access-inventory-from-custom-action-plugin-v2/22358>\
**Category:** Ansible Developer\
**Created:** [August 23, 2016, 9:13am UTC](https://forum.ansible.com/t/how-to-access-inventory-from-custom-action-plugin-v2/22358 "2016-08-23T09:13:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Kinley](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@James\_Kinley](https://forum.ansible.com/u/James_Kinley)\
**Post date:** [August 23, 2016, 9:13am UTC](https://forum.ansible.com/t/how-to-access-inventory-from-custom-action-plugin-v2/22358/1 "2016-08-23T09:13:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [August 23, 2016, 1:39pm UTC](https://forum.ansible.com/t/how-to-access-inventory-from-custom-action-plugin-v2/22358/2 "2016-08-23T13:39:20Z")

</div>

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