# jinja2 templated variables do not expand

**URL:** <https://forum.ansible.com/t/jinja2-templated-variables-do-not-expand/25770>\
**Category:** Ansible Project\
**Created:** [October 18, 2017, 5:28pm UTC](https://forum.ansible.com/t/jinja2-templated-variables-do-not-expand/25770 "2017-10-18T17:28:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![eray](https://avatars.discourse-cdn.com/v4/letter/e/ecd19e/32.png) [@eray](https://forum.ansible.com/u/eray)\
**Post date:** [October 18, 2017, 5:28pm UTC](https://forum.ansible.com/t/jinja2-templated-variables-do-not-expand/25770/1 "2017-10-18T17:28:42Z")

</div>

I am not sure if its my misuse of jinja within ansible, but I am seeing strange behavior from what would seem to be a typical use case for managing dynamic variables. As you can see from the code below, I am using the mysql\_os variable to determine the list to select items from. This may be the intended behavior, but I swear I have done this in the past. I tested on 2.3, and 2.2 with the same results.

`

---

<div class="post-metadata">

**Author:** ![mcsontos](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@mcsontos](https://forum.ansible.com/u/mcsontos)\
**Post date:** [October 19, 2017, 8:19am UTC](https://forum.ansible.com/t/jinja2-templated-variables-do-not-expand/25770/2 "2017-10-19T08:19:15Z")

</div>

If I remember correctly, it does not work, when you define a variable and try to use it in same “block” in this case vars:

Both mysql\_os and mysql\_el6\_base are defined in vars, so when expanding mysql\_el6\_base the mysql\_os is not yet defined.

And the solution I used was to separate them into multiple vars\_files.
