Equivalent of this inventory_hostname in groups['dev'] or inventory_hostname in groups['lb']

188 views
Skip to first unread message

ursa Brown

unread,
Feb 2, 2021, 3:44:26 PM2/2/21
to Ansible Project

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.

Matt Martz

unread,
Feb 2, 2021, 3:52:12 PM2/2/21
to ansible...@googlegroups.com
There are a number of alternatives

inventory_hostname in (groups.dev + groups.lb)

inventory_hostname in lookup('inventory_hostnames', 'dev:lb')

['dev', 'lb']|intersection(group_names)

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/505a2e16-378e-42c3-94b7-34976ef94e88n%40googlegroups.com.


--
Matt Martz
@sivel
sivel.net
Reply all
Reply to author
Forward
0 new messages