# Best practices with app/database dependencies

**URL:** <https://forum.ansible.com/t/best-practices-with-app-database-dependencies/16274>\
**Category:** Ansible Project\
**Created:** [September 18, 2014, 2:13pm UTC](https://forum.ansible.com/t/best-practices-with-app-database-dependencies/16274 "2014-09-18T14:13:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Strahinja\_Kustudic2](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@Strahinja\_Kustudic2](https://forum.ansible.com/u/Strahinja_Kustudic2)\
**Post date:** [September 18, 2014, 2:13pm UTC](https://forum.ansible.com/t/best-practices-with-app-database-dependencies/16274/1 "2014-09-18T14:13:38Z")

</div>

A lot of applications depend on a database and since databases are used very often, we usually have a separate role for installing a database and a role for installing an application. So if we have two roles: **db** and **app** , and **app** role depends on a database, in which role is it better to created the needed database and possibly the database user which is needed for that app?

Is it better to create it in the db role, e.g. by passing a variable to the db role in the dependency section; or in the app role itself? There are advantages and disadvantages to both of these, but we can discuss them later on.

---

<div class="post-metadata">

**Author:** ![Michael\_Peters](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@Michael\_Peters](https://forum.ansible.com/u/Michael_Peters)\
**Post date:** [September 18, 2014, 2:16pm UTC](https://forum.ansible.com/t/best-practices-with-app-database-dependencies/16274/2 "2014-09-18T14:16:53Z")

</div>

I prefer to have my application role depend on my database role and  
then have my application role setup the things it needs like users and  
databases. That way my database role is re-usable for other  
applications have their own database and user needs.
