# vars\_files-When are the variables loaded?

**URL:** <https://forum.ansible.com/t/vars-files-when-are-the-variables-loaded/19957>\
**Category:** Ansible Project\
**Created:** [December 7, 2015, 9:09pm UTC](https://forum.ansible.com/t/vars-files-when-are-the-variables-loaded/19957 "2015-12-07T21:09:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![smalleni](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@smalleni](https://forum.ansible.com/u/smalleni)\
**Post date:** [December 7, 2015, 9:09pm UTC](https://forum.ansible.com/t/vars-files-when-are-the-variables-loaded/19957/1 "2015-12-07T21:09:08Z")

</div>

In one my plays, a task executes a script that parses a file and exracts some credentials and saves them to a yaml file. If I try to access the variables in the file using vars\_files it doesn’t work as I guess ansible tries to figure out the values of the variables even before any of the tasks are executed. Since the tasks that sets up the yaml file isn’t executed, ansible complains that the variable file isn’t present. Even if try a task that writes the credentials to /etc/ansible/facts.d in json and try accessing them, ansible complains that the the ansible\_local variable isn’t present. Any workaround for this?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [December 7, 2015, 10:43pm UTC](https://forum.ansible.com/t/vars-files-when-are-the-variables-loaded/19957/2 "2015-12-07T22:43:08Z")

</div>

vars\_files executes in the 'playbook compile phase' if you want to  
dynamically load vars use include\_vars module.
