Sometimes you need to grab a particular variable from all hosts in a group in order to pass it into another role. For example, lets say you have a dns_servers
group in your inventory, and you want to get the ip addresses for all servers in that group so you can configure the remaining servers to use them for DNS queries.
Ansible gives you variables about hosts in the hostvars
object structured as shown below (i have omitted most of the vars for clarity):
{
"dns-1": {
"ansible_local": {
"net": {
"internal": {
"ip": "10.0.0.11"