# Syntax Issues for When Conditional

**URL:** <https://forum.ansible.com/t/syntax-issues-for-when-conditional/25280>\
**Category:** Ansible Project\
**Created:** [August 17, 2017, 3:18pm UTC](https://forum.ansible.com/t/syntax-issues-for-when-conditional/25280 "2017-08-17T15:18:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Huang](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@Mark\_Huang](https://forum.ansible.com/u/Mark_Huang)\
**Post date:** [August 17, 2017, 3:18pm UTC](https://forum.ansible.com/t/syntax-issues-for-when-conditional/25280/1 "2017-08-17T15:18:04Z")

</div>

Hi,

What is the proper syntax for trying to do something like this? It works fine but it gives me a warning that says not to use templating delimiters.

when: “{{ customer }}.aws\_cloud\_formation\_state == ‘present’”

I have tried just doing

when: customer.aws\_cloud\_formation\_state == ‘present’

but that just goes into the customer dictionary looking for aws\_cloud\_formation. I would like to take a variable ‘customer’ and use it as the conditional. It works fine, but what is the correct syntax for getting it to work without giving a warning.

Thank you!  
Mark

---

<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:** [August 18, 2017, 8:03pm UTC](https://forum.ansible.com/t/syntax-issues-for-when-conditional/25280/2 "2017-08-18T20:03:00Z")

</div>

You need to use vars

when: vars[customer].aws\_cloud\_formation\_state == 'present'

---

<div class="post-metadata">

**Author:** ![Mark\_Huang](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@Mark\_Huang](https://forum.ansible.com/u/Mark_Huang)\
**Post date:** [August 18, 2017, 9:06pm UTC](https://forum.ansible.com/t/syntax-issues-for-when-conditional/25280/3 "2017-08-18T21:06:42Z")

</div>

That did the trick!

Thank you!
