# vars precedence

**URL:** <https://forum.ansible.com/t/vars-precedence/27823>\
**Category:** Ansible Project\
**Created:** [June 19, 2018, 4:12pm UTC](https://forum.ansible.com/t/vars-precedence/27823 "2018-06-19T16:12:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dead\_gardens](https://avatars.discourse-cdn.com/v4/letter/d/cdc98d/32.png) [@dead\_gardens](https://forum.ansible.com/u/dead_gardens)\
**Post date:** [June 19, 2018, 4:12pm UTC](https://forum.ansible.com/t/vars-precedence/27823/1 "2018-06-19T16:12:07Z")

</div>

Hello there!

I’m having issues with vars precedence, hope you can help me here.

I’m currently using geerlingguy.ansible-role-postgresql as a dependency of my own postgresql role. Is define as a dependency in meta and I’m using import\_role in my main task.

I was using vars/main.yml on my own role to override the defaults but now I need to extend my own role a bit like defining diferent variables depending from which group is the server in the inventory.

For this I use group\_vars but with the vars/main.yml hack is impossible to override.

What would be the best practice here?

Best,  
Miracle Max

---

<div class="post-metadata">

**Author:** ![Laurent\_Hoss](https://avatars.discourse-cdn.com/v4/letter/l/7ba0ec/32.png) [@Laurent\_Hoss](https://forum.ansible.com/u/Laurent_Hoss)\
**Post date:** [June 13, 2019, 3:08pm UTC](https://forum.ansible.com/t/vars-precedence/27823/2 "2019-06-13T15:08:22Z")

</div>

> For this I use group\_vars but with the vars/main.yml hack is impossible to override.

- An earlier post with the same or similar question:  
[https://groups.google.com/d/msg/ansible-project/jFf1KfoWxBA/KXmcsQZqAQAJ](https://groups.google.com/d/msg/ansible-project/jFf1KfoWxBA/KXmcsQZqAQAJ)

- Please upvote your favorite solution, in the proposals I gathered in following post:  
[https://github.com/ansible/proposals/pull/21#issuecomment-470048538](https://github.com/ansible/proposals/pull/21#issuecomment-470048538)
