# String templating issue in lookup plugin command

**URL:** <https://forum.ansible.com/t/string-templating-issue-in-lookup-plugin-command/30844>\
**Category:** Ansible Project\
**Created:** [July 23, 2019, 9:25am UTC](https://forum.ansible.com/t/string-templating-issue-in-lookup-plugin-command/30844 "2019-07-23T09:25:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MKPhil](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@MKPhil](https://forum.ansible.com/u/MKPhil)\
**Post date:** [July 23, 2019, 9:25am UTC](https://forum.ansible.com/t/string-templating-issue-in-lookup-plugin-command/30844/1 "2019-07-23T09:25:34Z")

</div>

I’ve got a Playbook that uses a lookup plugin to retrieve a value but I seem to have a string templating issue.

This is my playbook:

`

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [July 23, 2019, 9:33am UTC](https://forum.ansible.com/t/string-templating-issue-in-lookup-plugin-command/30844/2 "2019-07-23T09:33:08Z")

</div>

> I've got a Playbook that uses a lookup plugin to retrieve a value but I seem to have a string templating issue.
> 
> This is my playbook:
> 
> \>  
> ---  
> -name:retrieve password  
> hosts:localhost  
> gather\_facts:no
> 
> vars:  
> vmware\_user:"SOMEUSER"
> 
> ```
> \# This Doesn&#39;t work:
> vmware\_password:&quot;\{\{ lookup\(&#39;cyberarkpassword&#39;, AppID=&#39;myapp&#39;, Query=&#39;address=mydomain\.corp;username=\{\{ vmware\_user
> 
> ```
> 
> }}', Output='Password').password }}"
> 
> ```
> \# This works:
> \# vmware\_password: &quot;\{\{ lookup\(&#39;cyberarkpassword&#39;, AppID=&#39;myapp&#39;, Query=&#39;address=mydomain\.corp;username=SOMEUSER&#39;,
> 
> ```
> 
> Output='Password').password }}"  
> \>

The curly braces can't be nested, so in this case you try to use vars['vmware\_user'] instead.

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 23, 2019, 9:43am UTC](https://forum.ansible.com/t/string-templating-issue-in-lookup-plugin-command/30844/3 "2019-07-23T09:43:42Z")

</div>

You are already in template mode so you can't use {{ }} inside {{ }}.  
You need to use string concatenation with tilde, so I think this should work.

vmware\_password: "{{ lookup('cyberarkpassword', AppID='myapp', Query='address=mydomain.corp;username=' ~ vmware\_user, Output='Password').password }}"
