Proposal: Enable access to group variables without going through a known host
Author: Lars <@laashe>
Date: 2018/05/30
Status: New
Proposal type: feature
Motivation
When working with a role to set up and configure DNS, I came across the need to access group variables without necessarily knowing any specific hosts in the group. Specifically, I wanted to create a new DNS zone for a certain group, and I needed information on domain, two first octets of the IP, etc. I could define the necessary information in group_vars/target_group.yml, but to access them I have to go through a host in that group: {{ hostvars['some_host_in_target_group']['desired_group_variable'] }}. Since I don't necessarily know, or at least I don't need to know, any hosts in target_group, I would very much have liked to have some sort of the following syntax available instead: {{ groupvars['target_group']['desired_group_variable'] }}. This is a very specific use case, but I think there must be multiple other use cases in which this would be very useful.
You can do something like hostvars[groups.target_group.0].desired_group_variable to access a variable from group_vars without knowing the name of one of the hosts in the group.
Proposal: Enable access to group variables without going through a known host
Author: Lars <@laashe>
Date: 2018/05/30
Motivation
When working with a role to set up and configure DNS, I came across the need to access group variables without necessarily knowing any specific hosts in the group. Specifically, I wanted to create a new DNS zone for a certain group, and I needed information on domain, two first octets of the IP, etc. I could define the necessary information in
group_vars/target_group.yml
, but to access them I have to go through a host in that group:{{ hostvars['some_host_in_target_group']['desired_group_variable'] }}
. Since I don't necessarily know, or at least I don't need to know, any hosts intarget_group
, I would very much have liked to have some sort of the following syntax available instead:{{ groupvars['target_group']['desired_group_variable'] }}
. This is a very specific use case, but I think there must be multiple other use cases in which this would be very useful.