Fix existing token retrieval for k3s server (#534)

Signed-off-by: Jonathan Cremin <jonathan@crem.in>
This commit is contained in:
Jonathan Cremin
2026-05-27 22:44:42 +01:00
committed by GitHub
parent d1aab4d8b8
commit 611ca0bbaf
+2 -2
View File
@@ -271,7 +271,7 @@
when: token is not defined and hostvars[groups[server_group][0]].random_token is defined when: token is not defined and hostvars[groups[server_group][0]].random_token is defined
# noqa var-naming[no-role-prefix] # noqa var-naming[no-role-prefix]
ansible.builtin.set_fact: ansible.builtin.set_fact:
k3s_server_config: "{{ k3s_server_config | combine({'token': token}) }}" k3s_server_config: "{{ k3s_server_config | combine({'token': hostvars[groups[server_group][0]].random_token}) }}"
- name: Convert server config to YAML and write to file - name: Convert server config to YAML and write to file
when: not ansible_check_mode when: not ansible_check_mode
@@ -285,7 +285,7 @@
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
state: absent state: absent
path: "{{ k3s_server_env_file }}" path: "{{ k3s_server_env_file }}"
regexp: "^K3S_TOKEN=\\s*(?!{{ token | regex_escape }}\\s*$)" regexp: "^K3S_TOKEN=\\s*(?!{{ token | default('') | regex_escape }}\\s*$)"
- name: Reload systemd daemon - name: Reload systemd daemon
when: when: