--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/fd716817-e0a0-49f3-9be1-59a07fbf1887%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[..snip..]
> I can see how to check that webserver is part of dc1 (webserver,&dc1) but
> not sure how to build it with multiple "OR" on the "AND" (something like
> "webserver,&(dc1,dc2,dc3)" is what I'm looking for but it doesn't work)
Put the dc1, dc2 and dc3 group in a group called dc and then you can use
webserver:&dc
- hosts: localhost gather_facts: false tasks: - add_host: name: "{{ item }}" groups: target_hosts when: hostvars[item].group_names | intersect(['dc1', 'dc2', 'dc3']) loop: "{{ groups.webserver | union(groups.dbserver) }}"
- hosts: target_hosts tasks: - command: /bin/trueNot in a host pattern. no. If you can't do it in the inventory, you can do it with a dynamic group:- hosts: localhostgather_facts: falsetasks:- add_host:name: "{{ item }}"groups: target_hostswhen: hostvars[item].group_names | intersect(['dc1', 'dc2', 'dc3'])loop: "{{ groups.webserver | union(groups.dbserver) }}"- hosts: target_hoststasks:- command: /bin/true