# concatenate variables and strings in file lookup

**URL:** <https://forum.ansible.com/t/concatenate-variables-and-strings-in-file-lookup/20144>\
**Category:** Ansible Project\
**Created:** [January 7, 2016, 8:16pm UTC](https://forum.ansible.com/t/concatenate-variables-and-strings-in-file-lookup/20144 "2016-01-07T20:16:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Colin\_Byrne](https://avatars.discourse-cdn.com/v4/letter/c/ecd19e/32.png) [@Colin\_Byrne](https://forum.ansible.com/u/Colin_Byrne)\
**Post date:** [January 7, 2016, 8:16pm UTC](https://forum.ansible.com/t/concatenate-variables-and-strings-in-file-lookup/20144/1 "2016-01-07T20:16:17Z")

</div>

Hey so I have a list of developer names in a dictionary and I am trying to do a file lookup on their ssh key,

I want to dynamically build the file path for each key as opposed to specifying it the full path for each developer.

Here is my task:

`

---

<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:** [January 7, 2016, 9:27pm UTC](https://forum.ansible.com/t/concatenate-variables-and-strings-in-file-lookup/20144/2 "2016-01-07T21:27:18Z")

</div>

moustaches don't stack and concatenation (+) does not work outside moustaches:

authorized\_key: user=root key="{{ lookup('file', role\_path +  
'/files/public\_keys/' + item.1) }}"

---

<div class="post-metadata">

**Author:** ![Colin\_Byrne](https://avatars.discourse-cdn.com/v4/letter/c/ecd19e/32.png) [@Colin\_Byrne](https://forum.ansible.com/u/Colin_Byrne)\
**Post date:** [January 7, 2016, 9:46pm UTC](https://forum.ansible.com/t/concatenate-variables-and-strings-in-file-lookup/20144/3 "2016-01-07T21:46:28Z")

</div>

Ha, awesome. Thanks a lot Brian, you are the man…
