I have the following groups defined in my inventory:
[webservers]
[server_storage]
[server_ws1]
[webservers:children]
server_storage
server_ws1
During my play, I'm in need of getting the names of the children groups of group['webservers'] ONLY (I think of theese as 'subgroups')
So, let's say I would need to set_fact a variable that contains in this case, the list of strings:
- server_storage
- server_ws1
This would have to be dynamic, so if I add group 'server_ws2' to group['webservers'], this should return
- server_storage
- server_ws1
- server_ws2
I've been playing with the use of group_names, group['webservers'] (which doesn't return subgroups, but hostnames)
Basically, I need a simple way of getting a the list of subgroups of a specific group. Is this possible without the use of black magic?
UPDATE: The idea, is that the hosts could belong to more groups, but I need only the subgroups or children of webservers group. It's constant, no matter the host, the output should allways be the same.
By the way, this one didn't work How can I get a list of child groups in Ansible?, because it retuns all groups for the current host, I need only subgroups of the specified group.