where to put custom lookup plugin

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”.

'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.

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

yes. I have this structure:
~/myproject
~/myproject/lookup_plugins/mylookup
~/myproject/test.yml

but still,

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

yes. I have this structure:
~/myproject
~/myproject/lookup_plugins/mylookup
~/myproject/test.yml

still:

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

not mylookup.py?

it is exactly mylookup. not mylookup.py

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