fix(k3s-server): build delegated join arguments

- Preserve explicit per-host server initialization overrides\n- Build default join arguments from the delegated host variables\n- Keep initialization commands out of normal task output
This commit is contained in:
Timothy Stewart
2026-07-31 17:36:32 -05:00
committed by Techno Tim
parent 94dbffaef7
commit 1402f33108
2 changed files with 12 additions and 1 deletions
+11 -1
View File
@@ -11,9 +11,19 @@
ansible.builtin.command: ansible.builtin.command:
cmd: >- cmd: >-
systemd-run -p RestartSec=2 -p Restart=on-failure --unit=k3s-init systemd-run -p RestartSec=2 -p Restart=on-failure --unit=k3s-init
k3s server {{ hostvars[joining_master].server_init_args }} k3s server {{ joining_server_args }}
creates: "{{ systemd_dir }}/k3s-init.service" creates: "{{ systemd_dir }}/k3s-init.service"
delegate_to: "{{ joining_master }}" delegate_to: "{{ joining_master }}"
no_log: true
vars:
primary_master: "{{ groups[group_name_master | default('master')][0] }}"
primary_master_api: >-
{{ hostvars[primary_master].k3s_node_ip | split(',') | first | ansible.utils.ipwrap }}
joining_server_args: >-
{{ hostvars[joining_master].server_init_args | default('--server https://' +
primary_master_api + ':6443 --token ' +
(hostvars[joining_master].k3s_token | default(k3s_token)) + ' ' +
(hostvars[joining_master].extra_server_args | default(''))) }}
- name: Wait for primary registration of {{ joining_master }} - name: Wait for primary registration of {{ joining_master }}
ansible.builtin.command: ansible.builtin.command:
+1
View File
@@ -38,6 +38,7 @@
ansible.builtin.command: ansible.builtin.command:
cmd: systemd-run -p RestartSec=2 -p Restart=on-failure --unit=k3s-init k3s server {{ server_init_args }} cmd: systemd-run -p RestartSec=2 -p Restart=on-failure --unit=k3s-init k3s server {{ server_init_args }}
creates: "{{ systemd_dir }}/k3s-init.service" creates: "{{ systemd_dir }}/k3s-init.service"
no_log: true
when: ansible_hostname == hostvars[groups[group_name_master | default('master')][0]]['ansible_hostname'] when: ansible_hostname == hostvars[groups[group_name_master | default('master')][0]]['ansible_hostname']
- name: Wait for the first master Kubernetes API before joining other masters - name: Wait for the first master Kubernetes API before joining other masters