# Equivalent of this inventory\_hostname in groups\['dev'\] or inventory\_hostname in groups\['lb'\]

**URL:** <https://forum.ansible.com/t/equivalent-of-this-inventory-hostname-in-groups-dev-or-inventory-hostname-in-groups-lb/34556>\
**Category:** Ansible Project\
**Created:** [February 2, 2021, 8:44pm UTC](https://forum.ansible.com/t/equivalent-of-this-inventory-hostname-in-groups-dev-or-inventory-hostname-in-groups-lb/34556 "2021-02-02T20:44:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ursa\_Brown](https://avatars.discourse-cdn.com/v4/letter/u/eb9ed0/32.png) [@ursa\_Brown](https://forum.ansible.com/u/ursa_Brown)\
**Post date:** [February 2, 2021, 8:44pm UTC](https://forum.ansible.com/t/equivalent-of-this-inventory-hostname-in-groups-dev-or-inventory-hostname-in-groups-lb/34556/1 "2021-02-02T20:44:26Z")

</div>

Is there a shortcut way for this?  
inventory\_hostname in groups[‘dev’] or inventory\_hostname in groups[‘lb’]  
I have a long playbook, im trying to cut some text.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [February 2, 2021, 8:51pm UTC](https://forum.ansible.com/t/equivalent-of-this-inventory-hostname-in-groups-dev-or-inventory-hostname-in-groups-lb/34556/2 "2021-02-02T20:51:19Z")

</div>

There are a number of alternatives

inventory\_hostname in ([groups.dev](http://groups.dev) + [groups.lb](http://groups.lb))

inventory\_hostname in lookup(‘inventory\_hostnames’, ‘dev:lb’)

[‘dev’, ‘lb’]|intersection(group\_names)
