where to put custom lookup plugin

28 views
Skip to first unread message

Gregory Edigarov

unread,
Oct 11, 2022, 11:06:02 AM10/11/22
to ansible...@googlegroups.com
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".

Brian Coca

unread,
Oct 11, 2022, 11:30:07 AM10/11/22
to ansible...@googlegroups.com
'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.

--
----------
Brian Coca

Rowe, Walter P. (Fed)

unread,
Oct 11, 2022, 11:32:29 AM10/11/22
to ansible...@googlegroups.com
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
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAMB-ck405M08M1SDiKRz6jDQTPSXjSefnWbP6w0OaGJBp10_Cw%40mail.gmail.com.

gregory....@gmail.com

unread,
Oct 11, 2022, 11:54:12 AM10/11/22
to Ansible Project
yes. I have this structure:
~/myproject
~/myproject/lookup_plugins/mylookup
~/myproject/test.yml

but still,
fatal: [localhost]: FAILED! => {"msg": "lookup plugin (mylookup) not found"}

gregory....@gmail.com

unread,
Oct 11, 2022, 11:56:47 AM10/11/22
to Ansible Project
yes. I have this structure:
~/myproject
~/myproject/lookup_plugins/mylookup
~/myproject/test.yml

still:

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


Brian Coca

unread,
Oct 11, 2022, 12:12:44 PM10/11/22
to ansible...@googlegroups.com
not mylookup.py?



--
----------
Brian Coca

gregory....@gmail.com

unread,
Oct 11, 2022, 12:43:50 PM10/11/22
to Ansible Project
it is exactly mylookup. not mylookup.py

gregory....@gmail.com

unread,
Oct 11, 2022, 12:50:10 PM10/11/22
to Ansible Project
renamed to mylookup.py at least it now finds the plugin. Thank you.
Reply all
Reply to author
Forward
0 new messages