Problem with variable interpolation in conditional

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

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.