# intersection of groups in inventory

**URL:** <https://forum.ansible.com/t/intersection-of-groups-in-inventory/34656>\
**Category:** Ansible Project\
**Created:** [February 19, 2021, 6:15pm UTC](https://forum.ansible.com/t/intersection-of-groups-in-inventory/34656 "2021-02-19T18:15:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Eggleston](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@Mike\_Eggleston](https://forum.ansible.com/u/Mike_Eggleston)\
**Post date:** [February 19, 2021, 6:15pm UTC](https://forum.ansible.com/t/intersection-of-groups-in-inventory/34656/1 "2021-02-19T18:15:38Z")

</div>

Hi,

In my inventory file I have “[linux]” and “[development]” groups. I want to patch the intersection of those groups. I know for one I can “ansible-playbook —limit linux patching.yml”, but how do I do the intersection?

Mike

---

<div class="post-metadata">

**Author:** ![Richard\_Megginson](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/richard_megginson/32/4540_2.png) [@Richard\_Megginson](https://forum.ansible.com/u/Richard_Megginson)\
**Post date:** [February 19, 2021, 6:32pm UTC](https://forum.ansible.com/t/intersection-of-groups-in-inventory/34656/2 "2021-02-19T18:32:53Z")

</div>

Something like this? [https://docs.ansible.com/ansible/2.9/user\_guide/intro\_patterns.html#common-patterns](https://docs.ansible.com/ansible/2.9/user_guide/intro_patterns.html#common-patterns)

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [February 19, 2021, 7:30pm UTC](https://forum.ansible.com/t/intersection-of-groups-in-inventory/34656/3 "2021-02-19T19:30:22Z")

</div>

Or Mike could add this to the inventory file

[patching:children]  
linux  
development

And use this group in patching.yml.

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![acozine1](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@acozine1](https://forum.ansible.com/u/acozine1)\
**Post date:** [February 19, 2021, 7:43pm UTC](https://forum.ansible.com/t/intersection-of-groups-in-inventory/34656/4 "2021-02-19T19:43:14Z")

</div>

Hi Mike,

The syntax is:

linux:&development

See [https://docs.ansible.com/ansible/latest/user\_guide/intro\_patterns.html#common-patterns](https://docs.ansible.com/ansible/latest/user_guide/intro_patterns.html#common-patterns) for a handy cheatsheet of common patterns.

Alicia Cozine

She/Her

Lead Technical Writer, Ansible  
[Red Hat](https://www.redhat.com/)

[acozine@redhat.com](mailto:acozine@redhat.com)

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [February 19, 2021, 7:45pm UTC](https://forum.ansible.com/t/intersection-of-groups-in-inventory/34656/5 "2021-02-19T19:45:23Z")

</div>

> > Something like this? [https://docs.ansible.com/ansible/2.9/user\_guide/intro\_patterns.html#common-patterns](https://docs.ansible.com/ansible/2.9/user_guide/intro_patterns.html#common-patterns)
> > 
> > > Hi,
> > > 
> > > In my inventory file I have “[linux]” and “[development]” groups. I want to patch the intersection of those groups. I  
> > > know for one I can “ansible-playbook —limit linux patching.yml”, but how do I do the intersection?
> > > 
> > > Mike
> 
> Or Mike could add this to the inventory file
> 
> [patching:children]  
> linux  
> development
> 
> And use this group in patching.yml.

Sorry misread the post, this what would be the union, not the intersectoin.

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Mike\_Eggleston](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@Mike\_Eggleston](https://forum.ansible.com/u/Mike_Eggleston)\
**Post date:** [February 19, 2021, 9:07pm UTC](https://forum.ansible.com/t/intersection-of-groups-in-inventory/34656/6 "2021-02-19T21:07:34Z")

</div>

Works great. Thank you!

Mike
