Evaluating 'or' in when: conditional

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!

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’

`