# Value of 'inject' param in lookup plugins

**URL:** <https://forum.ansible.com/t/value-of-inject-param-in-lookup-plugins/12810>\
**Category:** Ansible Project\
**Created:** [May 15, 2013, 2:58pm UTC](https://forum.ansible.com/t/value-of-inject-param-in-lookup-plugins/12810 "2013-05-15T14:58:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Darren\_Worrall](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@Darren\_Worrall](https://forum.ansible.com/u/Darren_Worrall)\
**Post date:** [May 15, 2013, 2:58pm UTC](https://forum.ansible.com/t/value-of-inject-param-in-lookup-plugins/12810/1 "2013-05-15T14:58:30Z")

</div>

Is it expected that lookup plugins get a different value for ‘inject’ depending on how they’re called in a playbook? Here’s a simple test case: [https://gist.github.com/DazWorrall/5584358](https://gist.github.com/DazWorrall/5584358) - in the first case, ‘inject’ is a collection of host/group/fact data, in the second case its a function (which when called, doesnt return the same data as in the first case).

Thanks

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [May 15, 2013, 5:58pm UTC](https://forum.ansible.com/t/value-of-inject-param-in-lookup-plugins/12810/2 "2013-05-15T17:58:46Z")

</div>

I’m not sure I really understand what your lookup plugin is supposed to do.

I’m also not sure why you think inject is a function.

---

<div class="post-metadata">

**Author:** ![Darren\_Worrall](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@Darren\_Worrall](https://forum.ansible.com/u/Darren_Worrall)\
**Post date:** [May 15, 2013, 7:29pm UTC](https://forum.ansible.com/t/value-of-inject-param-in-lookup-plugins/12810/3 "2013-05-15T19:29:38Z")

</div>

The lookup plugin in the gist is purely to demonstrate the difference in behaviour, showing that the value of inject when you use the lookup function in a jinja template is the builtin vars function[0](http://docs.python.org/2/library/functions.html#vars), you can see it passed in here[1](https://github.com/ansible/ansible/blob/devel/lib/ansible/utils/template.py#L84).

We have a lookup plugin which reads host data from the value of inject when you call the plugin using the `with_foo` syntax - not sure if that the right thing to do but it works in the `with_foo` case. The value is inconsistent depending on how its called from a playbook, I’m not sure if that’s a bug, or that we just shouldn’t be relying on the value of that parameter inside a lookup plugin.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [May 15, 2013, 8:01pm UTC](https://forum.ansible.com/t/value-of-inject-param-in-lookup-plugins/12810/4 "2013-05-15T20:01:17Z")

</div>

I think the vars error was leftover when the lookup function was defined in a closure.

Please make sure there’s a github ticket filed on this one and I’ll take care of it.
