A cluster needs a per-host list of all peers except itself.
IntermediateScenarioVariables, Facts and Templates
Answer
Situation read → Peer lists in templates.
What I'd do →
{% for h in groups['cluster'] if h != inventory_hostname %}
peer {{ hostvars[h].ansible_host | default(h) }}
{% endfor %}
Or in YAML: {{ groups['cluster'] | difference([inventory_hostname]) }}.
Why → difference is clean and testable; the loop-with-if form is fine inside templates.
Interview tip → ansible_play_hosts is better than groups[...] when you want only hosts still alive in this run.
More on Variables, Facts and Templates
A variable you set in `group_vars` is being overridden and you do not know where. How do you find the source?IntermediateYou need different values per environment without copying playbooks.BeginnerYou must render an Nginx config with one `server` block per site from a list.IntermediateA template needs the IPs of all hosts in the `db` group, for example for a replication config.IntermediateNothing should be rendered unless a mandatory variable is supplied.BeginnerPer-host values, like `server_id` for MySQL, must be unique and stable.Intermediate