# (Derived) variable resolution bug?

**URL:** <https://forum.ansible.com/t/derived-variable-resolution-bug/17725>\
**Category:** Ansible Project\
**Created:** [March 12, 2015, 3:04am UTC](https://forum.ansible.com/t/derived-variable-resolution-bug/17725 "2015-03-12T03:04:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ananda\_Debnath](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Ananda\_Debnath](https://forum.ansible.com/u/Ananda_Debnath)\
**Post date:** [March 12, 2015, 3:04am UTC](https://forum.ansible.com/t/derived-variable-resolution-bug/17725/1 "2015-03-12T03:04:43Z")

</div>

_Is this a bug or am I misunderstanding how variables are resolved based on precedence? According to [http://docs.ansible.com/playbooks\_variables.html,](http://docs.ansible.com/playbooks_variables.html,)_

> ```auto
> * extra vars (-e in the command line) always win
> * then comes connection variables defined in inventory (ansible_ssh_user, etc)
> * then comes "most everything else" (command line switches, vars in play, included vars, role vars, etc)
> * then comes the rest of the variables defined in inventory
> * then comes facts discovered about a system
> * then "role defaults", which are the most "defaulty" and lose in priority to everything.
> 
> ```

# The setup

robin@hood:~/AnsiblePlaybooks/ExtraVars$ tree  
±- extravars.yml  
±- inventory  
±- roles  
±- testextravars  
±- tasks  
¦ ±- main.yml  
±- vars  
±- extravars.json  
±- main.yml

_# The playbook_

robin@hood:~/AnsiblePlaybooks/ExtraVars$ cat extravars.yml

---

<div class="post-metadata">

**Author:** ![Ananda\_Debnath](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Ananda\_Debnath](https://forum.ansible.com/u/Ananda_Debnath)\
**Post date:** [March 12, 2015, 3:33pm UTC](https://forum.ansible.com/t/derived-variable-resolution-bug/17725/2 "2015-03-12T15:33:42Z")

</div>

A friend at work was wondering whether this has to do with the location of the extravars.json file - I moved it out to the base directory of the ansible project and added another var to make sure the extravars.json file was being loaded - with no difference in results.

robin@hood:~/AnsiblePlaybooks/ExtraVars$ cat roles/testextravars/vars/extravars.json  
{  
“basevar”: “override”  
“extravar”: “some extra var”  
}

I also changed the task to be:

---

<div class="post-metadata">

**Author:** ![Ananda\_Debnath](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Ananda\_Debnath](https://forum.ansible.com/u/Ananda_Debnath)\
**Post date:** [April 2, 2015, 7:30pm UTC](https://forum.ansible.com/t/derived-variable-resolution-bug/17725/3 "2015-04-02T19:30:18Z")

</div>

_ping_

---

<div class="post-metadata">

**Author:** ![Ananda\_Debnath](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Ananda\_Debnath](https://forum.ansible.com/u/Ananda_Debnath)\
**Post date:** [April 2, 2015, 7:55pm UTC](https://forum.ansible.com/t/derived-variable-resolution-bug/17725/4 "2015-04-02T19:55:31Z")

</div>

Known bug: [https://github.com/ansible/ansible/issues/10251](https://github.com/ansible/ansible/issues/10251) and [https://github.com/ansible/ansible/issues/10564](https://github.com/ansible/ansible/issues/10564)
