# Having problems with a variable in vars\_files

**URL:** <https://forum.ansible.com/t/having-problems-with-a-variable-in-vars-files/29685>\
**Category:** Ansible Project\
**Created:** [February 14, 2019, 5:35pm UTC](https://forum.ansible.com/t/having-problems-with-a-variable-in-vars-files/29685 "2019-02-14T17:35:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_O\_Mahony](https://avatars.discourse-cdn.com/v4/letter/b/da6949/32.png) [@Brian\_O\_Mahony](https://forum.ansible.com/u/Brian_O_Mahony)\
**Post date:** [February 14, 2019, 5:35pm UTC](https://forum.ansible.com/t/having-problems-with-a-variable-in-vars-files/29685/1 "2019-02-14T17:35:59Z")

</div>

I am having an issue with referencing a variable in var\_files module, and cant for the life of me figure it out. I am generating some vars in a playbook, and using setfact on them [basically awk shell commands to strip arts of the ansible control node hostname]

If i debug the var before hand I can see it, but the play returns an undefined variable:

**Playbook:**

---

<div class="post-metadata">

**Author:** ![Sudarshan\_V](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@Sudarshan\_V](https://forum.ansible.com/u/Sudarshan_V)\
**Post date:** [February 16, 2019, 12:04am UTC](https://forum.ansible.com/t/having-problems-with-a-variable-in-vars-files/29685/2 "2019-02-16T00:04:15Z")

</div>

Hi,

Try

vars\_files:

- vars/“{{ dcenv }}”.yml
- vars/vault

---

<div class="post-metadata">

**Author:** ![Brian\_O\_Mahony](https://avatars.discourse-cdn.com/v4/letter/b/da6949/32.png) [@Brian\_O\_Mahony](https://forum.ansible.com/u/Brian_O_Mahony)\
**Post date:** [February 18, 2019, 12:47pm UTC](https://forum.ansible.com/t/having-problems-with-a-variable-in-vars-files/29685/3 "2019-02-18T12:47:02Z")

</div>

I had tried that previous, and it is the same issue.

---

<div class="post-metadata">

**Author:** ![Sudarshan\_V](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@Sudarshan\_V](https://forum.ansible.com/u/Sudarshan_V)\
**Post date:** [February 18, 2019, 10:39pm UTC](https://forum.ansible.com/t/having-problems-with-a-variable-in-vars-files/29685/4 "2019-02-18T22:39:00Z")

</div>

Ok, it is unclear what you are trying to accomplish.  
try import\_vars

---

<div class="post-metadata">

**Author:** ![Sudarshan\_V](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@Sudarshan\_V](https://forum.ansible.com/u/Sudarshan_V)\
**Post date:** [February 18, 2019, 10:50pm UTC](https://forum.ansible.com/t/having-problems-with-a-variable-in-vars-files/29685/5 "2019-02-18T22:50:23Z")

</div>

Have a look at  
[https://docs.ansible.com/ansible/latest/modules/include\_vars\_module.html](https://docs.ansible.com/ansible/latest/modules/include_vars_module.html)

---

<div class="post-metadata">

**Author:** ![Darkhan](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@Darkhan](https://forum.ansible.com/u/Darkhan)\
**Post date:** [February 19, 2019, 2:08pm UTC](https://forum.ansible.com/t/having-problems-with-a-variable-in-vars-files/29685/6 "2019-02-19T14:08:53Z")

</div>

Can you run your playbook with -vvv then post the output? It’s probably going to be a lot, so use [https://pastebin.com/](https://pastebin.com/) .  
Check if beforehand for any sensitive information.

---

<div class="post-metadata">

**Author:** ![Brian\_O\_Mahony](https://avatars.discourse-cdn.com/v4/letter/b/da6949/32.png) [@Brian\_O\_Mahony](https://forum.ansible.com/u/Brian_O_Mahony)\
**Post date:** [February 20, 2019, 11:52am UTC](https://forum.ansible.com/t/having-problems-with-a-variable-in-vars-files/29685/7 "2019-02-20T11:52:13Z")

</div>

Will do. I am actually not in the office until Monday so will send it then.
