# how to refactor a play consisting of multiple roles into a single role?

**URL:** <https://forum.ansible.com/t/how-to-refactor-a-play-consisting-of-multiple-roles-into-a-single-role/14920>\
**Category:** Ansible Project\
**Created:** [April 2, 2014, 12:55pm UTC](https://forum.ansible.com/t/how-to-refactor-a-play-consisting-of-multiple-roles-into-a-single-role/14920 "2014-04-02T12:55:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gallagher\_Polyn](https://avatars.discourse-cdn.com/v4/letter/g/94ad74/32.png) [@Gallagher\_Polyn](https://forum.ansible.com/u/Gallagher_Polyn)\
**Post date:** [April 2, 2014, 12:55pm UTC](https://forum.ansible.com/t/how-to-refactor-a-play-consisting-of-multiple-roles-into-a-single-role/14920/1 "2014-04-02T12:55:41Z")

</div>

I’d like to convert a playbook consisting of several (3) roles into a role (the playbook: [github.com/leucos/ansible-rbenv-playbook](http://github.com/leucos/ansible-rbenv-playbook)).

It seems odd that I would flatten the several roles back into plays, but I haven’t seen examples of a role consisting of roles.

What is the recommended approach for making a role from a playbook consisting of several roles?

Thanks, G

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 2, 2014, 3:46pm UTC](https://forum.ansible.com/t/how-to-refactor-a-play-consisting-of-multiple-roles-into-a-single-role/14920/2 "2014-04-02T15:46:45Z")

</div>

Having a play map server roles to a host group is pretty simple:

- hosts: webservers  
roles:
- role\_a
- role\_b
- role\_c

Some users may like role dependencies but they are usually overkill, and I don’t use them hardly ever myself.

(It is true of course that a role doesn’t consist of roles - it’s made up of tasks, handlers, variables (defaults and ones that are strictly observed, and metadata)
