# Best way to Include Roles in tasks

**URL:** <https://forum.ansible.com/t/best-way-to-include-roles-in-tasks/20085>\
**Category:** Ansible Project\
**Created:** [December 29, 2015, 12:08am UTC](https://forum.ansible.com/t/best-way-to-include-roles-in-tasks/20085 "2015-12-29T00:08:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Colin\_Byrne](https://avatars.discourse-cdn.com/v4/letter/c/ecd19e/32.png) [@Colin\_Byrne](https://forum.ansible.com/u/Colin_Byrne)\
**Post date:** [December 29, 2015, 12:08am UTC](https://forum.ansible.com/t/best-way-to-include-roles-in-tasks/20085/1 "2015-12-29T00:08:37Z")

</div>

So I used to have one fairly long main.yml playbook that was used to perform a number of similar-tasks, one of which was to install rbenv, the ruby management tool.

---

<div class="post-metadata">

**Author:** ![Borys\_Borysenko](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@Borys\_Borysenko](https://forum.ansible.com/u/Borys_Borysenko)\
**Post date:** [December 29, 2015, 9:03am UTC](https://forum.ansible.com/t/best-way-to-include-roles-in-tasks/20085/2 "2015-12-29T09:03:50Z")

</div>

Hello Colin,

The most simple way I guess is just to split your playbook with pre\_tasks, roles and tasks sections. Something similar to:

---

<div class="post-metadata">

**Author:** ![Colin\_Byrne](https://avatars.discourse-cdn.com/v4/letter/c/ecd19e/32.png) [@Colin\_Byrne](https://forum.ansible.com/u/Colin_Byrne)\
**Post date:** [December 29, 2015, 9:12am UTC](https://forum.ansible.com/t/best-way-to-include-roles-in-tasks/20085/3 "2015-12-29T09:12:03Z")

</div>

Hey, Thanks for the reply… This is already in a role though, so would calling a role from a role make sense or even work?  
Thanks, C

---

<div class="post-metadata">

**Author:** ![chrismeyersfsu](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chrismeyersfsu/32/1016_2.png) [@chrismeyersfsu](https://forum.ansible.com/u/chrismeyersfsu)\
**Post date:** [December 30, 2015, 3:38am UTC](https://forum.ansible.com/t/best-way-to-include-roles-in-tasks/20085/4 "2015-12-30T03:38:25Z")

</div>

The only way you can invoke a role from within a role is via [meta/main.yml](http://docs.ansible.com/ansible/playbooks_roles.html#role-dependencies) You may not explicitly invoke a role within a role like you do tasks.
