# where to put custom lookup plugin

**URL:** <https://forum.ansible.com/t/where-to-put-custom-lookup-plugin/37205>\
**Category:** Ansible Project\
**Created:** [October 11, 2022, 3:05pm UTC](https://forum.ansible.com/t/where-to-put-custom-lookup-plugin/37205 "2022-10-11T15:05:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gregory\_Edigarov](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Gregory\_Edigarov](https://forum.ansible.com/u/Gregory_Edigarov)\
**Post date:** [October 11, 2022, 3:05pm UTC](https://forum.ansible.com/t/where-to-put-custom-lookup-plugin/37205/1 "2022-10-11T15:05:35Z")

</div>

Hello guys,

As a part of my project, I’ve written a lookup module and put it into lookup\_plugins directory in the root of it:  
project/lookup\_plugins/mylookup

i am calling this module as:

- name: test  
debug:  
msg: “the next soa serial for zone: {{ item }} is  
{{ lookup (‘mylookup’ ,item) }}”

loop:

- test1
- test2

but ansible raises an error:  
fatal: [localhost]: FAILED! =\> {“msg”: “lookup plugin (mylookup) not found”}

citing the official documentation:  
“You can activate a custom lookup by either dropping it into a lookup\_plugins directory adjacent to your play”.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [October 11, 2022, 3:28pm UTC](https://forum.ansible.com/t/where-to-put-custom-lookup-plugin/37205/2 "2022-10-11T15:28:18Z")

</div>

'project' means nothing to ansible, the lookup\_plugins dir must be  
adjacent to play, so if play files are in the 'project' directory, it  
will work.

You also have other options, like putting it in a collection, role or  
installing in the configured paths for the plugin.

---

<div class="post-metadata">

**Author:** ![Walter\_Rowe](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/walter_rowe/32/4506_2.png) [@Walter\_Rowe](https://forum.ansible.com/u/Walter_Rowe)\
**Post date:** [October 11, 2022, 3:32pm UTC](https://forum.ansible.com/t/where-to-put-custom-lookup-plugin/37205/3 "2022-10-11T15:32:09Z")

</div>

Is your playbook in a subfolder of your project?

/myproject  
/myproject/lookup\_plugins/mylookup  
/myproject/myfolder/myplaybook

The error seems to indicate the lookup\_plugins should be in the same folder as the playbook

/myproject/myfolder/lookup\_plugins/mylookup  
/myproject/myfolder/myplaybook

I haven’t used this before, but that is how I interpret the error message.

Walter

---

<div class="post-metadata">

**Author:** ![Gregory\_Edigarov](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Gregory\_Edigarov](https://forum.ansible.com/u/Gregory_Edigarov)\
**Post date:** [October 11, 2022, 3:54pm UTC](https://forum.ansible.com/t/where-to-put-custom-lookup-plugin/37205/4 "2022-10-11T15:54:12Z")

</div>

yes. I have this structure:  
~/myproject  
~/myproject/lookup\_plugins/mylookup  
~/myproject/test.yml

but still,

fatal: [localhost]: FAILED! =\> {“msg”: “lookup plugin (mylookup) not found”}

---

<div class="post-metadata">

**Author:** ![Gregory\_Edigarov](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Gregory\_Edigarov](https://forum.ansible.com/u/Gregory_Edigarov)\
**Post date:** [October 11, 2022, 3:56pm UTC](https://forum.ansible.com/t/where-to-put-custom-lookup-plugin/37205/5 "2022-10-11T15:56:47Z")

</div>

yes. I have this structure:  
~/myproject  
~/myproject/lookup\_plugins/mylookup  
~/myproject/test.yml

still:

fatal: [localhost]: FAILED! =\> {“msg”: “lookup plugin (mylookup) not found”}

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [October 11, 2022, 4:11pm UTC](https://forum.ansible.com/t/where-to-put-custom-lookup-plugin/37205/6 "2022-10-11T16:11:05Z")

</div>

not mylookup.py?

---

<div class="post-metadata">

**Author:** ![Gregory\_Edigarov](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Gregory\_Edigarov](https://forum.ansible.com/u/Gregory_Edigarov)\
**Post date:** [October 11, 2022, 4:43pm UTC](https://forum.ansible.com/t/where-to-put-custom-lookup-plugin/37205/7 "2022-10-11T16:43:50Z")

</div>

it is exactly mylookup. not mylookup.py

---

<div class="post-metadata">

**Author:** ![Gregory\_Edigarov](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Gregory\_Edigarov](https://forum.ansible.com/u/Gregory_Edigarov)\
**Post date:** [October 11, 2022, 4:50pm UTC](https://forum.ansible.com/t/where-to-put-custom-lookup-plugin/37205/8 "2022-10-11T16:50:10Z")

</div>

renamed to mylookup.py at least it now finds the plugin. Thank you.
