# problem with group intersections

**URL:** <https://forum.ansible.com/t/problem-with-group-intersections/13168>\
**Category:** Ansible Project\
**Created:** [July 19, 2013, 10:37pm UTC](https://forum.ansible.com/t/problem-with-group-intersections/13168 "2013-07-19T22:37:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Martin2](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@James\_Martin2](https://forum.ansible.com/u/James_Martin2)\
**Post date:** [July 19, 2013, 10:37pm UTC](https://forum.ansible.com/t/problem-with-group-intersections/13168/1 "2013-07-19T22:37:21Z")

</div>

For some reason I can't get the group intersection to work. As you  
can see I have a CentOS group and a riakcs\_cluster group, and then I  
want to run some plays on the intersection of those two groups, but it  
seems like the intersection results in only one host (10.42.0.6).  
What am I doing wrong?

- James

PLAY [all:!localhost] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [10.42.0.200]  
ok: [10.42.0.100]  
ok: [10.42.0.7]  
ok: [10.42.0.6]  
ok: [10.42.0.8]

TASK: [Create groups based on distribution] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [10.42.0.100] =\> {"changed": true, "groups": {"CentOS":  
["10.42.0.100", "10.42.0.200", "10.42.0.6", "10.42.0.7",  
"10.42.0.8"]}}

PLAY [localhost] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [127.0.0.1]

TASK: [debug msg="{{groups['CentOS']}}"] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [127.0.0.1] =\> {"msg": "['10.42.0.6', '10.42.0.7', '10.42.0.8',  
'10.42.0.200', '10.42.0.100']"}

TASK: [debug msg="{{groups['riakcs\_cluster']}}"] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [127.0.0.1] =\> {"msg": "['10.42.0.7', '10.42.0.6', '10.42.0.8']"}

PLAY [CentOS:&riakcs\_cluster] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK: [fetch yum repository] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [10.42.0.6] =\> {"changed": false, "dest":  
"/tmp/basho-release-6-1.noarch.rpm", "gid": 0, "group": "root",  
"item": "", "mode": "0644", "msg": "file already exists", "owner":  
"root", "size": 11311, "state": "file", "uid": 0, "url":  
"[http://yum.basho.com/gpg/basho-release-6-1.noarch.rpm&quot;\](http://yum.basho.com/gpg/basho-release-6-1.noarch.rpm&quot;%5C)}

TASK: [configure the basho repository] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [10.42.0.6] =\> {"changed": false, "item": "", "msg": "", "rc": 0,  
"results": }

TASK: [install riak, riak-cs] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [10.42.0.6] =\> (item=riak-1.3.1,riak-cs-1.3.1) =\> {"changed":  
false, "item": "riak-1.3.1,riak-cs-1.3.1", "msg": "", "rc": 0,  
"results": ["riak-1.3.1-1.el6.x86\_64 providing riak-1.3.1 is already  
installed", "riak-cs-1.3.1-1.el6.x86\_64 providing riak-cs-1.3.1 is  
already installed"]}

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 19, 2013, 11:36pm UTC](https://forum.ansible.com/t/problem-with-group-intersections/13168/2 "2013-07-19T23:36:00Z")

</div>

Can I see the playbook?

---

<div class="post-metadata">

**Author:** ![James\_Martin2](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@James\_Martin2](https://forum.ansible.com/u/James_Martin2)\
**Post date:** [July 19, 2013, 11:39pm UTC](https://forum.ansible.com/t/problem-with-group-intersections/13168/3 "2013-07-19T23:39:51Z")

</div>

- hosts: all:!localhost  
&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;- name: Create groups based on distribution  
&nbsp;&nbsp;&nbsp;&nbsp;group\_by: key={{ ansible\_distribution }}

- hosts: localhost  
&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;- debug: msg="{{ groups['CentOS'] }}"  
&nbsp;&nbsp;- debug: msg="{{ groups['riakcs\_cluster'] }}"

- hosts: CentOS:&riakcs\_cluster  
&nbsp;&nbsp;gather\_facts: no  
&nbsp;&nbsp;sudo: True  
&nbsp;&nbsp;roles:  
&nbsp;&nbsp;- bootstrap/redhat  
&nbsp;&nbsp;- riak/redhat  
&nbsp;&nbsp;- riak/common  
&nbsp;&nbsp;- riakcs/redhat  
&nbsp;&nbsp;- riakcs/common

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 21, 2013, 12:27pm UTC](https://forum.ansible.com/t/problem-with-group-intersections/13168/4 "2013-07-21T12:27:55Z")

</div>

Thanks, I have the github ticket now, so it’s in queue.
