# roles, when, hostvars and conditionals  || error while evaluating conditional: X==X

**URL:** <https://forum.ansible.com/t/roles-when-hostvars-and-conditionals-error-while-evaluating-conditional-x-x/17672>\
**Category:** Ansible Project\
**Created:** [March 5, 2015, 8:49am UTC](https://forum.ansible.com/t/roles-when-hostvars-and-conditionals-error-while-evaluating-conditional-x-x/17672 "2015-03-05T08:49:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jakub\_Muszynski](https://avatars.discourse-cdn.com/v4/letter/j/c68b51/32.png) [@Jakub\_Muszynski](https://forum.ansible.com/u/Jakub_Muszynski)\
**Post date:** [March 5, 2015, 8:49am UTC](https://forum.ansible.com/t/roles-when-hostvars-and-conditionals-error-while-evaluating-conditional-x-x/17672/1 "2015-03-05T08:49:09Z")

</div>

Hi

I have faced a syntax/jinja/bug? issue while evalutating conditionals in ‘when’  
`{role: restart, action: restart, app: web, when: "{{ hostvars[groups['web'][0]]['result']['state'] }}" == 'SUSPENDED']} #Not working {role: restart, action: restart, app: web, when: "{{'SUSPEND' in hostvars[groups['web'][0]]['result']['state'] }}"} #Working`

I’m not sure is that a bug, I did find a way to ‘play it’ but it was not clear.  
I’ll make this post for future ansible users 🙂

playbook:

`
