# Evaluating 'or' in when: conditional

**URL:** <https://forum.ansible.com/t/evaluating-or-in-when-conditional/17381>\
**Category:** Ansible Project\
**Created:** [January 27, 2015, 3:04am UTC](https://forum.ansible.com/t/evaluating-or-in-when-conditional/17381 "2015-01-27T03:04:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Barry\_Morrison](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@Barry\_Morrison](https://forum.ansible.com/u/Barry_Morrison)\
**Post date:** [January 27, 2015, 3:04am UTC](https://forum.ansible.com/t/evaluating-or-in-when-conditional/17381/1 "2015-01-27T03:04:36Z")

</div>

I have a task with a  
`when: "'web' in group_names"`

and it work as I expect it to, only running against servers in a web group.

But now I want the conditional to match on web _or_ db.

I expected something like:

`when: "'web' or 'db' in group_names"`

would work, but it does not. Neither does

`when: "'web' in group_names" or "'db' in group_names"`

I’ve also tried most variations of the above.

How can I get a task to _only_ run if ‘web’ OR ‘db’ exist in the group\_name?

Thanks!

---

<div class="post-metadata">

**Author:** ![Barry\_Morrison](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@Barry\_Morrison](https://forum.ansible.com/u/Barry_Morrison)\
**Post date:** [January 27, 2015, 4:16am UTC](https://forum.ansible.com/t/evaluating-or-in-when-conditional/17381/2 "2015-01-27T04:16:11Z")

</div>

I got some help via #ansible and was able to figure out what was happening. Some insight:

`

- debug: msg=“a web or db {{group\_names}}”  
when: ‘“web” in group\_names or “db” in group\_names’

`
