# How to share template between two roles?

**URL:** <https://forum.ansible.com/t/how-to-share-template-between-two-roles/17932>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [April 8, 2015, 3:51pm UTC](https://forum.ansible.com/t/how-to-share-template-between-two-roles/17932 "2015-04-08T15:51:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [April 8, 2015, 3:51pm UTC](https://forum.ansible.com/t/how-to-share-template-between-two-roles/17932/1 "2015-04-08T15:51:16Z")

</div>

Roles are intended to be independent things, so sharing files between them doesn’t make a lot of sense. One thing you could do, if these two roles are that similar, is to combine them into a single role and add a variable to defaults which set the mode, for instance “dbservers\_mode: master”. Then you could have something like this in your tasks/main.yml:

- include: “{{dbservers\_mode}}.yml”

And then the master.yml/slave.yml files would be the tasks/main.yml from each of the individual roles.

Hope that helps!
