<p dir="auto">According to the documentation, " plugins can be shipped in a subdirectory relative to a top-level playbook", and this used to work in v1.</p>
<p dir="auto">With v2 however, this does not work (at least for lookup_plugins) unless the "lookup_plugins" subdirectory is explicitly mentioned in ansible.cfg.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ mkdir lookup_plugins
$ cp $ANSIBLE_ROOT/lib/ansible/plugins/lookup/items.py lookup_plugins/myitems
$ cat test_lookup_pl.yml 

---
- hosts: localhost
  tasks:
    - name: Print items from custom lookup plugin
      debug: msg=&quot;Item= {{ item }} &quot;
      with_myitems:
        - foo
        - bar
$ ansible-playbook test_lookup_pl.yml
PLAY ****************************************************************************

TASK [setup] ********************************************************************
ok: [localhost]

TASK [Print items from custom lookup plugin] ************************************
fatal: [localhost]: FAILED! =&gt; {&quot;failed&quot;: true, &quot;msg&quot;: &quot;ERROR! the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'item' is undefined&quot;}

PLAY RECAP **********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1   


Now if I create an ansible.cfg file:
$ cat ansible.cfg
[defaults]
lookup_plugins=./lookup_plugins

$ ansible-playbook test_lookup_pl.yml
PLAY ****************************************************************************

TASK [setup] ********************************************************************

ok: [localhost]

TASK [Print items from custom lookup plugin] ************************************
ok: [localhost] =&gt; (item=foo) =&gt; {
    &quot;item&quot;: &quot;foo&quot;, 
    &quot;msg&quot;: &quot;Item= foo &quot;
}
ok: [localhost] =&gt; (item=bar) =&gt; {
    &quot;item&quot;: &quot;bar&quot;, 
    &quot;msg&quot;: &quot;Item= bar &quot;
}
ok: [localhost]

PLAY RECAP **********************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0   "><pre class="notranslate"><code class="notranslate">$ mkdir lookup_plugins
$ cp $ANSIBLE_ROOT/lib/ansible/plugins/lookup/items.py lookup_plugins/myitems
$ cat test_lookup_pl.yml 

---
- hosts: localhost
  tasks:
    - name: Print items from custom lookup plugin
      debug: msg="Item= {{ item }} "
      with_myitems:
        - foo
        - bar
$ ansible-playbook test_lookup_pl.yml
PLAY ****************************************************************************

TASK [setup] ********************************************************************
ok: [localhost]

TASK [Print items from custom lookup plugin] ************************************
fatal: [localhost]: FAILED! =&gt; {"failed": true, "msg": "ERROR! the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'item' is undefined"}

PLAY RECAP **********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1   


Now if I create an ansible.cfg file:
$ cat ansible.cfg
[defaults]
lookup_plugins=./lookup_plugins

$ ansible-playbook test_lookup_pl.yml
PLAY ****************************************************************************

TASK [setup] ********************************************************************

ok: [localhost]

TASK [Print items from custom lookup plugin] ************************************
ok: [localhost] =&gt; (item=foo) =&gt; {
    "item": "foo", 
    "msg": "Item= foo "
}
ok: [localhost] =&gt; (item=bar) =&gt; {
    "item": "bar", 
    "msg": "Item= bar "
}
ok: [localhost]

PLAY RECAP **********************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0   
</code></pre></div>
<p dir="auto">I was making an ansible-galaxy role today and when placing the lookup_folder plugin at the same level as the rest of the folders and then using it it returns that it can't find the plugin. Do we have anyway to use lookup_plugins at a role level without forcing uses to manually add it to there playbook?</p>
<p dir="auto">Here is the repo in question. Master is how i got it to work for testing that the lookup_plugins folder only works when at the same level as the playbook <a href="https://github.com/nowait-tools/ansible-rabbitmq">https://github.com/nowait-tools/ansible-rabbitmq</a> the branch galaxy test is the one that fails.</p>