Group hosts by value from list object of inventory var

31 views
Skip to first unread message

Mook

unread,
Apr 27, 2015, 11:24:19 AM4/27/15
to ansible...@googlegroups.com
Hi.
I have an inventory like this:

[test_servers]
192.168.0.101 app_roles='["relay_master"]'
192.168.0.102 app_roles='["relay_slave","cache","web_master"]'
192.168.0.103 app_roles='["relay_slave","cache","web_slave"]'

Is it possible to add servers that, for example, have "cache" in their app_roles to a group (like with group_by)?

Brian Coca

unread,
Apr 27, 2015, 3:40:29 PM4/27/15
to ansible...@googlegroups.com
yes, but I find it easier to just create groups for that

[test_servers]
192.168.0.101

[relay_masters]
192.168.0.101
10.10.1.101
and then have the plays target the servers, using --limit to restrict
to 'test_servers':

- hosts: relay_masters

or just make them separate inventories sharing group/host_vars and
choose with -i /inventories/testing

Mook

unread,
Apr 28, 2015, 5:14:33 AM4/28/15
to ansible...@googlegroups.com
Came to the same conclusion. Thanks for confirming.
Reply all
Reply to author
Forward
0 new messages