I want to create a configuration file on all the servers containing all the different locations and the number of members in each location. Example:
location1: 2,
location2: 1,
location3: 3
The number of different loc_names can vary. Is there a simple Jinja2 template that can yield those results? I’m worried that I’m approaching this from the wrong angle or that I set up the inventory in a way that is anti-Ansible; I want to avoid creating a convoluted template file if at all possible.
Unfortunately, I may have made the example too simple. The actual inventory file has more groups and not all the groups are just locations. Furthermore, the group names are not necessarily the same as the “loc_name” variable. For example, in addition to the location groups, we could have groups like: