# Problem with variable interpolation in conditional

**URL:** <https://forum.ansible.com/t/problem-with-variable-interpolation-in-conditional/24979>\
**Category:** Ansible Project\
**Created:** [July 13, 2017, 11:44pm UTC](https://forum.ansible.com/t/problem-with-variable-interpolation-in-conditional/24979 "2017-07-13T23:44:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guy\_Knights](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Guy\_Knights](https://forum.ansible.com/u/Guy_Knights)\
**Post date:** [July 13, 2017, 11:44pm UTC](https://forum.ansible.com/t/problem-with-variable-interpolation-in-conditional/24979/1 "2017-07-13T23:44:38Z")

</div>

I’m really confused about a problem I’m having with a conditional statement in a playbook. The task is below:

- action: fail  
when: “‘App: {{ app\_id }}’ not in response.content”

When I run the playbook I get this error:

[WARNING]: when statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: ‘Client: {{  
wl\_name }}’ not in response.content

As I suspected, when I removed the curly brackets the task failed because “App: app\_id” was of course not in the output.

How then am I supposed to interpolate the variable app\_id in this when condition?

Thanks,  
Guy

---

<div class="post-metadata">

**Author:** ![Guy\_Knights](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Guy\_Knights](https://forum.ansible.com/u/Guy_Knights)\
**Post date:** [July 13, 2017, 11:49pm UTC](https://forum.ansible.com/t/problem-with-variable-interpolation-in-conditional/24979/2 "2017-07-13T23:49:46Z")

</div>

Never mind - of course I worked this out right after I sent my initial post.

The solution is to use when: “'App: ’ + app\_id not in response.content”, for those who might also be caught out by this.
