# using variable from another file

**URL:** <https://forum.ansible.com/t/using-variable-from-another-file/30966>\
**Category:** Ansible Project\
**Created:** [August 6, 2019, 2:42pm UTC](https://forum.ansible.com/t/using-variable-from-another-file/30966 "2019-08-06T14:42:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noctis\_Geek](https://avatars.discourse-cdn.com/v4/letter/n/71c47a/32.png) [@Noctis\_Geek](https://forum.ansible.com/u/Noctis_Geek)\
**Post date:** [August 6, 2019, 2:42pm UTC](https://forum.ansible.com/t/using-variable-from-another-file/30966/1 "2019-08-06T14:42:26Z")

</div>

Hello, I would like to know the syntax that would allow me to retrieve the contents of a file and use it to make a variable in a new file in my example I have my YAML configuration file and I have a VARIABLE file and I do not know how to get my first line and make it a variable in my 1st file

############ config.yml ############

---

<div class="post-metadata">

**Author:** ![Sebastian\_Meyer](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Sebastian\_Meyer](https://forum.ansible.com/u/Sebastian_Meyer)\
**Post date:** [August 6, 2019, 2:44pm UTC](https://forum.ansible.com/t/using-variable-from-another-file/30966/2 "2019-08-06T14:44:03Z")

</div>

See:

[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_variables.html#defining-variables-in-files](https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#defining-variables-in-files)

Sebastian

---

<div class="post-metadata">

**Author:** ![Noctis\_Geek](https://avatars.discourse-cdn.com/v4/letter/n/71c47a/32.png) [@Noctis\_Geek](https://forum.ansible.com/u/Noctis_Geek)\
**Post date:** [August 6, 2019, 2:48pm UTC](https://forum.ansible.com/t/using-variable-from-another-file/30966/3 "2019-08-06T14:48:03Z")

</div>

thanks for this, but if i come here it’s for get help, i already read the doc

```auto

```

```auto

```

```auto

```

---

<div class="post-metadata">

**Author:** ![PhilEv](https://avatars.discourse-cdn.com/v4/letter/p/ee59a6/32.png) [@PhilEv](https://forum.ansible.com/u/PhilEv)\
**Post date:** [August 7, 2019, 12:10pm UTC](https://forum.ansible.com/t/using-variable-from-another-file/30966/4 "2019-08-07T12:10:30Z")

</div>

So Sebastian did provide the answer and help 😉

Hint: read the vars\_files in the the provided links

Phil
