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' 


TASK: [_nrpe | debug msg="a web or db {{group_names}}"] 
**************************** 
skipping: [web1.prod.domain.net] 
skipping: [web2.prod.domain.net]

TASK: [_nrpe | debug var=group_names] 
***************************************** 
ok: [web1.prod.domain.net] => { 
 "group_names": [ 
 "prod-web" 
 ] 
} 
ok: [web2.prod.domain.net] => { 
 "group_names": [ 
 "prod-web" 
 ] 
} 


So it actually works when I have group_names as prod-web and I match on 
when: "'web' in group_names' but it doesn't work when I have 
[prod|build]-web so I leveraged groups of groups and created a 
[web:children] with prod-web and dev-web as a part of the group, then the 
match on 'web' works. 

On Monday, January 26, 2015 at 7:04:36 PM UTC-8, Barry Morrison wrote:
>
> 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!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/bf067d43-e2dd-4715-ad35-1b219e22eb8c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to