# Variable substitution while file lookup

**URL:** <https://forum.ansible.com/t/variable-substitution-while-file-lookup/22784>\
**Category:** Ansible Project\
**Created:** [October 13, 2016, 1:03pm UTC](https://forum.ansible.com/t/variable-substitution-while-file-lookup/22784 "2016-10-13T13:03:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankur.cool](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@ankur.cool](https://forum.ansible.com/u/ankur.cool)\
**Post date:** [October 13, 2016, 1:03pm UTC](https://forum.ansible.com/t/variable-substitution-while-file-lookup/22784/1 "2016-10-13T13:03:41Z")

</div>

Hi,

I am loading a file using lookup eg “{{ lookup(‘file’, ‘cluster\_policies.json’) | from\_json }}”

Now my file cluster\_policies.json contains some ansible variables that I need to substitute. Any idea how can it be done?

Thanks

---

<div class="post-metadata">

**Author:** ![ankur.cool](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@ankur.cool](https://forum.ansible.com/u/ankur.cool)\
**Post date:** [October 13, 2016, 1:33pm UTC](https://forum.ansible.com/t/variable-substitution-while-file-lookup/22784/2 "2016-10-13T13:33:16Z")

</div>

Ok i found an answer.  
{{ lookup(‘template’, ‘cluster\_policies.j2’) }}  
this works fine
