# lookup module didn't replace variable value that is given as file name

**URL:** <https://forum.ansible.com/t/lookup-module-didnt-replace-variable-value-that-is-given-as-file-name/17729>\
**Category:** Ansible Project\
**Created:** [March 12, 2015, 1:08pm UTC](https://forum.ansible.com/t/lookup-module-didnt-replace-variable-value-that-is-given-as-file-name/17729 "2015-03-12T13:08:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [March 12, 2015, 1:08pm UTC](https://forum.ansible.com/t/lookup-module-didnt-replace-variable-value-that-is-given-as-file-name/17729/1 "2015-03-12T13:08:20Z")

</div>

Hi,

I have problem with the lookup module, I am given the file name as a variable, it takes it but didn’t replace the variable with it’s value. For example:

pub\_subnet: “{{ lookup(‘file’, ‘./vars/{{ vpc\_name }}\_public\_subnet.yml’) }}”

When I run the playbook, it should replace it with the variable name: tendo\_public\_subnet.yml

But it is giving me an error of:

TASK: [VPC | set the facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [localhost] =\> could not locate file in lookup: ./vars/{{ vpc\_name }}\_public\_subnet.yml

FATAL: all hosts have already failed – aborting

Can somebody point me that where I am making a mistake.

Thanks

---

<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:** [March 12, 2015, 3:51pm UTC](https://forum.ansible.com/t/lookup-module-didnt-replace-variable-value-that-is-given-as-file-name/17729/2 "2015-03-12T15:51:01Z")

</div>

Too many moustaches!

{{ }} are not stackable, try the following:

pub\_subnet: "{{ lookup('file', './vars/' + vpc\_name + ' \_public\_subnet.yml') }}"

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [March 12, 2015, 5:35pm UTC](https://forum.ansible.com/t/lookup-module-didnt-replace-variable-value-that-is-given-as-file-name/17729/3 "2015-03-12T17:35:58Z")

</div>

Hi Brain,

Bundles of Thanks, it’s work for me.

If you don’t mind, can you please also give me your valuable comment here:  
[https://groups.google.com/forum/#!topic/ansible-project/Zyb1X4clSWU](https://groups.google.com/forum/#!topic/ansible-project/Zyb1X4clSWU)

Thanks
