title: Ansible playbook which uses a role defined in a collection
body: <p>This is an example of an Ansible playbook I am currently playing around with:</p>
  <pre class="lang-yaml prettyprint-override"><code>---
  - hosts: all
  
    collections:
      - mynamespace.my_collection
  
    roles:
      - mynamespace.my_role1
      - mynamespace.my_role2
      - geerlingguy.repo-remi
  </code></pre>
  <p>The <code>mynamespace.my_collection</code> collection is a custom collection that contains a couple of roles, namely <code>mynamespace.my_role1</code> and <code>mynamespace.my_role2</code>.</p>
  <p>I have a <code>requirements.yml</code> file as follows:</p>
  <pre class="lang-yaml prettyprint-override"><code>---
  collections:
    - name: git@github.com:mynamespace/my_collection.git
  
  roles:
    - name: geerlingguy.repo-remi
      version: &quot;2.0.1&quot;
  </code></pre>
  <p>And I install the collection and roles as follows:</p>
  <pre><code>ansible-galaxy collection install -r /home/ansible/requirements.yml --force
  ansible-galaxy role install -r /home/ansible/requirements.yml --force
  </code></pre>
  <p>Each time I attempt to run the playbook it fails with the following error:</p>
  <pre><code>ERROR! the role 'mynamespace.my_role1' was not found in mynamespace.my_collection:ansible.legacy:/home/ansible/roles:/home/ansible_roles:/home/ansible
  
  The error appears to be in '/home/ansible/play.yml': line 42, column 7, but may
  be elsewhere in the file depending on the exact syntax problem.
  
  The offending line appears to be:
  
    roles:
      - mynamespace.my_role1
        ^ here
  </code></pre>
  <p>For the avoidance of doubt, I have tried multiple ways of defining the roles in the playbook including <code>mynamespace.my_collection.my_role1</code> (the fully qualified name of the role within the collection).</p>
  <p>I suspect I've done something wrong or misunderstood how it should work but my understanding is a collection can contain multiple roles and once that collection is installed, I should be able to call upon one or more of the roles within the collection inside my playbook to use it but it doesn't seem to be working for me.</p>
  <p>The error seems to suggest it is looking for the role inside the collection but not finding it.</p>
  <p>The collection is installed to the path <code>/home/ansible_collections/mynamespace/my_collection</code> and within that directory is <code>roles/my_role1</code> and <code>roles/my_role2</code>.</p>
  <p>Maybe the structure of the roles inside the collection is wrong?</p>
  <p>I'm using Ansible 2.10 on CentOS 8.</p>
  <p>Thanks for any advice!</p>
  <p>EDIT:</p>
  <p>I just wanted to expand on something I alluded to earlier. I believe the docs say the fully qualified name should be used to reference the role in the collection within the playbook.</p>
  <p>Unfortunately, this errors too:</p>
  <pre><code>ERROR! the role 'mynamespace.my_collection.my_role1' was not found in mynamespace.my_collection:ansible.legacy:/home/ansible/roles:/home/ansible_roles:/home/ansible
  
  The error appears to be in '/home/ansible/play.yml': line 42, column 7, but may
  be elsewhere in the file depending on the exact syntax problem.
  
  The offending line appears to be:
  
    roles:
      - mynamespace.my_collection.my_role1
        ^ here
  </code></pre>