Are there any possible ways to check if registered variables (hostnames) with a loop are in inventory and print their groups?
I am creating a role to install heartbeat with ansible role. But it will be installed only on one jumphost which will ping the other.
Inside this role i have created separated files and put config for each host in them. But i need to add some fields to to find out which group they belong to (we need it in Kibana).
I used Jinja templates but it paste the group that owns the host I play the role.
{% for group in group_names %}
group: {{ group }}
{% endfor %}
so I started to search if there is any way in ansible itself to do it. I
- name: list of hosts
debug:
msg: "{{ item }}"
with_items:
- "{{ groups['all'] }}"
it returned hosts and i would like compare this list with list in our inventory and get their group names to paste them to the icmp.yml configs of heartbeat