# Inventory path in ansible plugin

**URL:** <https://forum.ansible.com/t/inventory-path-in-ansible-plugin/28151>\
**Category:** Ansible Developer\
**Created:** [July 25, 2018, 4:08pm UTC](https://forum.ansible.com/t/inventory-path-in-ansible-plugin/28151 "2018-07-25T16:08:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ansiblekrazy](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@ansiblekrazy](https://forum.ansible.com/u/ansiblekrazy)\
**Post date:** [July 25, 2018, 4:08pm UTC](https://forum.ansible.com/t/inventory-path-in-ansible-plugin/28151/1 "2018-07-25T16:08:28Z")

</div>

How to get inventory path in call back plugin:

I found this, however it is not working.. I’m developing my plugin where I need inventory path to work on other things. Any help will be appreciated

In short, is there a way to check which parameter is used for what in

v2\_playbook\_on\_start(self, playbook):

| 
# On Ansible v2, Ansible doesn’t set `self.playbook` automatically
 |
| | 

self.playbook = playbook

 |
| | |
| | 

playbook\_file\_name = self.playbook.\_file\_name

 |
| | 

inventory = self.\_options.inventory

 |
| | |
| | 

self.start\_timer()

 |
| | |
| | 
# Set the playbook name from its filename
 |
| | 

self.\_playbook\_name, \_ = os.path.splitext(

 |
| | 

os.path.basename(playbook\_file\_name))

 |
| | 

if isinstance(inventory, list):

 |
| | 

inventory = ‘,’.join(inventory)

 |
| | 

self.\_inventory\_name = ‘,’.join([os.path.basename(os.path.realpath(name)) for name in inventory.split(‘,’) if name])

 |

---

<div class="post-metadata">

**Author:** ![ansiblekrazy](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@ansiblekrazy](https://forum.ansible.com/u/ansiblekrazy)\
**Post date:** [July 25, 2018, 4:47pm UTC](https://forum.ansible.com/t/inventory-path-in-ansible-plugin/28151/2 "2018-07-25T16:47:22Z")

</div>

Any help immediately will be appreciated

---

<div class="post-metadata">

**Author:** ![Andrew\_Gaffney](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@Andrew\_Gaffney](https://forum.ansible.com/u/Andrew_Gaffney)\
**Post date:** [July 25, 2018, 4:52pm UTC](https://forum.ansible.com/t/inventory-path-in-ansible-plugin/28151/3 "2018-07-25T16:52:59Z")

</div>

If you want “immediate” help, then a mailing list is often not the right place to go.

There is no “official” way to get the name of the inventory file from a callback plugin. This is also complicated by the inventory overhaul in 2.4, which allows multiple inventory files. Any hack that you come up with can easily break in future Ansible versions, as the information you want is not part of the “guaranteed” callback plugin interface.

---

<div class="post-metadata">

**Author:** ![ansiblekrazy](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@ansiblekrazy](https://forum.ansible.com/u/ansiblekrazy)\
**Post date:** [July 25, 2018, 4:58pm UTC](https://forum.ansible.com/t/inventory-path-in-ansible-plugin/28151/4 "2018-07-25T16:58:34Z")

</div>

Thank you for your reply… Andrew 🙂
