# Interpolation in Jinja2 default() values

**URL:** <https://forum.ansible.com/t/interpolation-in-jinja2-default-values/19178>\
**Category:** Ansible Project\
**Created:** [September 3, 2015, 4:45pm UTC](https://forum.ansible.com/t/interpolation-in-jinja2-default-values/19178 "2015-09-03T16:45:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Dillon](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@Mike\_Dillon](https://forum.ansible.com/u/Mike_Dillon)\
**Post date:** [September 3, 2015, 4:45pm UTC](https://forum.ansible.com/t/interpolation-in-jinja2-default-values/19178/1 "2015-09-03T16:45:57Z")

</div>

I’d like to do something like the following, but I couldn’t find anything in the docs or on the mailing list that made it clear whether this should be possible or not:

```auto
---
- name: add user keys from GitHub
  authorized_key:
    user: "{{item.user}}"
    key: "{{item.ssh_public_key | default(\"https://github.myenterprise.com/{{item.user}}.keys\")}}"
  with_items: users

```

When I tried to do this, I got an error message about not being able to fetch the key:

> msg: Error getting key from: [https://github.myenterprise.com/{#](https://github.myenterprise.com/%7B#) item.user #}.keys

I tried both escaping the default value with `\"` and using `'`, but got the same error each time.

Thanks!

-md

---

<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:** [September 3, 2015, 5:03pm UTC](https://forum.ansible.com/t/interpolation-in-jinja2-default-values/19178/2 "2015-09-03T17:03:07Z")

</div>

no mustache stacking!!!!

&nbsp;&nbsp;key: "{{item.ssh\_public\_key |  
default('[https://github.myenterprise.com/](https://github.myenterprise.com/)’ + item.user + '.keys')}}"

---

<div class="post-metadata">

**Author:** ![Mike\_Dillon](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@Mike\_Dillon](https://forum.ansible.com/u/Mike_Dillon)\
**Post date:** [September 8, 2015, 11:03pm UTC](https://forum.ansible.com/t/interpolation-in-jinja2-default-values/19178/3 "2015-09-08T23:03:50Z")

</div>

Thanks Brian! For some reason I didn’t get a notification for your response, so sorry for the delay.

-md
