title: Ansible role dependency handling for collections
body: <p>When creating an ansible role you can specify the dependencies in <code>meta/main.yml</code> as follows</p>
  <pre><code>dependencies:
  - role: papanito.xxx
  </code></pre>
  <p>How I do this, if <code>papanito.xxx</code> was converted into a collection? Or let's phrase it otherwise: How to I tell my role, that it depends on a module/role from a collection?</p>
  <p>If I run <code>ansible-playbook</code> which uses a role, that has a dependency to a role in a collection, get the following error:</p>
  <pre><code>ERROR! the role 'papanito.xxx' was not found in ansible.legacy:
  /home/papanito/Workspaces/devenv/roles:
  /home/papanito/.ansible/roles:
  /usr/share/ansible/roles:
  /etc/ansible/roles:
  /home/papanito/Workspaces/devenv/roles:
  /home/papanito/Workspaces/devenv
  </code></pre>
  <p>As I can see ansible checks these paths for roles, however, collections are stored under <code>/home/papanito/.ansible/collections/ansible_collections/</code>.</p>
  <p>I suspect this has to do with the mention of <a href="https://docs.ansible.com/ansible/latest/dev_guide/migrating_roles.html#using-ansible-legacy-to-access-local-custom-modules-from-collections-based-roles" rel="nofollow noreferrer"><code>ansible.legacy</code></a>, however I did not configure anything like that - intentionally at least.</p>
  <p>Using <code>role: the_namespace.the_collection.the_role</code> does not solve the problem, but I still get the same error.</p>
  <p>Further <a href="https://docs.ansible.com/ansible/latest/user_guide/collections_using.html#using-collections-in-roles" rel="nofollow noreferrer">the documentation</a> says</p>
  <blockquote>
  <p>Within a role, you can control which <code>collections</code> Ansible searches for the tasks inside the role using the collections keyword in the role’s <code>meta/main.yml</code></p>
  </blockquote>
  <p>So I updated <code>meta/main.yml</code> to</p>
  <pre class="lang-yaml prettyprint-override"><code>collections:
  - papanito.xxx
  dependencies:
  - role: papanito.xxx.xxx
  </code></pre>
  <p>Which still results in the exact same error as above when I run the playbook.</p>