# defaults vs vars precedence in dependent roles

**URL:** <https://forum.ansible.com/t/defaults-vs-vars-precedence-in-dependent-roles/18942>\
**Category:** Ansible Project\
**Created:** [August 4, 2015, 8:45pm UTC](https://forum.ansible.com/t/defaults-vs-vars-precedence-in-dependent-roles/18942 "2015-08-04T20:45:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Martin](https://avatars.discourse-cdn.com/v4/letter/a/77aa72/32.png) [@Andrew\_Martin](https://forum.ansible.com/u/Andrew_Martin)\
**Post date:** [August 4, 2015, 8:45pm UTC](https://forum.ansible.com/t/defaults-vs-vars-precedence-in-dependent-roles/18942/1 "2015-08-04T20:45:04Z")

</div>

Hello,

I have structured my roles such that redistributable roles, such as a role for installing mariadb, define as many of their variables in defaults/main.yml as possible. This way, any role that includes that redistributable role in its meta/main.yml can override that variable with a custom value by setting it in its vars/main.yml:

roles/mariadb/defaults/main.yml:

> * * *
> 
> mysql\_password: “password1234”

roles/myserver/meta/main.yml:

> * * *
> 
> dependencies:
> 
> - { role: mariadb }

roles/myserver/vars/main.yml:

> * * *
> 
> mysql\_password: “secretpassword”

Thus, myserver should have mysql\_password set to “secretpassword” when it is run. This has worked well until recently, when it stopped working completely (possibly when I upgraded to 1.9.x). Now, it seems that a custom value defined in vars/main.yml does not override a default value in a meta role. I prefer overriding the variables in vars/main.yml rather than needing to override them in meta/main.yml because that can become a long, messy list.

Has variable precedence behavior changed recently, or can anyone explain why this has stopped working?

Thanks,

Andrew Martin
