# Role imported from galaxy exists also as inner role

**URL:** <https://forum.ansible.com/t/role-imported-from-galaxy-exists-also-as-inner-role/34302>\
**Category:** Ansible Project\
**Tags:** galaxy-ng\
**Created:** [December 8, 2020, 5:15pm UTC](https://forum.ansible.com/t/role-imported-from-galaxy-exists-also-as-inner-role/34302 "2020-12-08T17:15:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmoullia](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@cmoullia](https://forum.ansible.com/u/cmoullia)\
**Post date:** [December 8, 2020, 5:15pm UTC](https://forum.ansible.com/t/role-imported-from-galaxy-exists-also-as-inner-role/34302/1 "2020-12-08T17:15:03Z")

</div>

Hi

When execute the following command

ansible-galaxy install -r requirements.yml

using this requirements.yml file

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [December 8, 2020, 5:42pm UTC](https://forum.ansible.com/t/role-imported-from-galaxy-exists-also-as-inner-role/34302/2 "2020-12-08T17:42:43Z")

</div>

The trick would be the repository owner not including that directory  
in the repository

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [December 8, 2020, 6:13pm UTC](https://forum.ansible.com/t/role-imported-from-galaxy-exists-also-as-inner-role/34302/3 "2020-12-08T18:13:32Z")

</div>

> What is the trick to fix that ?

The role's directory must be the repo's top level. It's not here  
[https://github.com/ch007m/galaxy-role/tree/main/role-1](https://github.com/ch007m/galaxy-role/tree/main/role-1)

See structure of the directories "Roles"  
[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_reuse\_roles.html](https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html)

and how to properly import a role

---

<div class="post-metadata">

**Author:** ![cmoullia](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@cmoullia](https://forum.ansible.com/u/cmoullia)\
**Post date:** [December 8, 2020, 6:17pm UTC](https://forum.ansible.com/t/role-imported-from-galaxy-exists-also-as-inner-role/34302/4 "2020-12-08T18:17:30Z")

</div>

Many thanks. Can we import a git project containing several roles ?

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [December 8, 2020, 8:04pm UTC](https://forum.ansible.com/t/role-imported-from-galaxy-exists-also-as-inner-role/34302/5 "2020-12-08T20:04:59Z")

</div>

Yes. Such a project is called a collection.  
[https://docs.ansible.com/ansible/latest/dev\_guide/developing\_collections.html#collection-structure](https://docs.ansible.com/ansible/latest/dev_guide/developing_collections.html#collection-structure)  
[https://github.com/ansible-collections/](https://github.com/ansible-collections/)

---

<div class="post-metadata">

**Author:** ![cmoullia](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@cmoullia](https://forum.ansible.com/u/cmoullia)\
**Post date:** [December 9, 2020, 8:37am UTC](https://forum.ansible.com/t/role-imported-from-galaxy-exists-also-as-inner-role/34302/6 "2020-12-09T08:37:52Z")

</div>

I did a test and the roles have been imported properly. Nevertheless I dont see how I would be able to consume them from tasks using “import\_roles” as it will be needed that I hard code the full path …

ansible-galaxy install -r requirements-roles.yml  
Starting galaxy collection install process  
Process install dependency map  
Starting collection install process

Installing ‘community.role-1:0.0.1’ to ‘/Users/cmoullia/.ansible/collections/ansible\_collections/community/role-1’  
Created collection for community.role-1 at /Users/cmoullia/.ansible/collections/ansible\_collections/community/role-1  
community.role-1 (0.0.1) was installed successfully

Installing ‘community.role-2:0.0.1’ to ‘/Users/cmoullia/.ansible/collections/ansible\_collections/community/role-2’  
Created collection for community.role-2 at /Users/cmoullia/.ansible/collections/ansible\_collections/community/role-2  
community.role-2 (0.0.1) was installed successfully
