Skip to content

Commit 532c76e

Browse files
committed
Determine active_server once per cluster, not once for all
While `first_server.yml` would only be included for the 1st server of a cluster, `run_once` for setting the `active_server` fact also meant this would only happen once for all clusters instead of once per cluster. Use a loop across the members of each cluster and a fact delegation instead, to set the `active_server` fact instead on each cluster member to the `inventory_hostname` of the server, for which `first_server.yml` was included.
1 parent 1f4dd6e commit 532c76e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tasks/first_server.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@
145145
- name: Set an Active Server variable
146146
ansible.builtin.set_fact:
147147
active_server: "{{ inventory_hostname }}"
148-
run_once: true
148+
delegate_to: "{{ item }}"
149+
delegate_facts: true
150+
loop: "{{ groups[rke2_cluster_group_name] }}"
149151

150152
- name: Get all nodes
151153
ansible.builtin.shell: |

0 commit comments

Comments
 (0)