Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix active_server for multi-cluster deployments #205

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion tasks/first_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@
- name: Set an Active Server variable
ansible.builtin.set_fact:
active_server: "{{ inventory_hostname }}"
run_once: true
delegate_to: "{{ item }}"
delegate_facts: true
loop: "{{ groups[rke2_cluster_group_name] }}"

- name: Get all nodes
ansible.builtin.shell: |
Expand Down
12 changes: 6 additions & 6 deletions tasks/remaining_nodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@
retries: 100
delay: 15
loop: "{{ groups[rke2_cluster_group_name] }}"
delegate_to: "{{ active_server | default(groups[rke2_servers_group_name].0) }}"
run_once: true
when: rke2_cni == 'none'
when:
- rke2_cni == 'none'
- inventory_hostname == active_server or inventory_hostname == groups[rke2_servers_group_name].0

- name: Wait for remaining nodes to be ready - with CNI
ansible.builtin.shell: |
Expand All @@ -89,6 +89,6 @@
"groups[rke2_cluster_group_name] | length == all_ready_nodes.stdout | int"
retries: 100
delay: 15
delegate_to: "{{ active_server | default(groups[rke2_servers_group_name].0) }}"
run_once: true
when: rke2_cni != 'none'
when:
- rke2_cni != 'none'
- inventory_hostname == active_server or inventory_hostname == groups[rke2_servers_group_name].0
5 changes: 1 addition & 4 deletions tasks/summary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
src: /etc/rancher/rke2/rke2.yaml
dest: "{{ rke2_download_kubeconf_path }}/{{ rke2_download_kubeconf_file_name }}"
flat: yes
delegate_to: "{{ groups[rke2_servers_group_name].0 }}"
run_once: true
when:
- rke2_download_kubeconf | bool
- inventory_hostname == groups[rke2_servers_group_name].0

- name: Replace loopback IP by master server IP
ansible.builtin.replace:
Expand All @@ -31,11 +30,9 @@
args:
executable: /bin/bash
changed_when: false
run_once: true
retries: 5
register: nodes_summary

- name: K8s nodes state
ansible.builtin.debug:
var: nodes_summary.stdout_lines
run_once: true
Loading