fix(token): escape percent signs used in k3s token (#682)

- systemd treats % as a specifier in ExecStart, so token values containing %
  fail with 'failed to resolve unit specifiers invalid slot'
- escape % to %% in the agent unit file
- escape % to %% in server_init_args so the multi-master bootstrap path
  (systemd-run k3s-init) handles % tokens too

Co-authored-by: finaldoom <677609+FinalDoom@users.noreply.github.com>
This commit is contained in:
Techno Tim
2026-08-02 14:27:17 -05:00
committed by GitHub
parent bb006cf157
commit 890d43b339
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/k3s agent \ ExecStart=/usr/local/bin/k3s agent \
--server https://{{ apiserver_endpoint | ansible.utils.ipwrap }}:6443 \ --server https://{{ apiserver_endpoint | ansible.utils.ipwrap }}:6443 \
{% if is_pxe_booted | default(false) %}--snapshotter native \ {% if is_pxe_booted | default(false) %}--snapshotter native \
{% endif %}--token {{ hostvars[groups[group_name_master | default('master')][0]]['token'] | default(k3s_token) }} \ {% endif %}--token {{ hostvars[groups[group_name_master | default('master')][0]]['token'] | default(k3s_token) | replace( '%', '%%' ) }} \
{{ extra_agent_args }} {{ extra_agent_args }}
KillMode=process KillMode=process
Delegate=yes Delegate=yes
+1 -1
View File
@@ -33,7 +33,7 @@ server_init_args: >-
{% else %} {% else %}
--server https://{{ hostvars[groups[group_name_master | default('master')][0]].k3s_node_ip | split(",") | first | ansible.utils.ipwrap }}:6443 --server https://{{ hostvars[groups[group_name_master | default('master')][0]].k3s_node_ip | split(",") | first | ansible.utils.ipwrap }}:6443
{% endif %} {% endif %}
--token {{ k3s_token }} --token {{ k3s_token | replace('%', '%%') }}
{% endif %} {% endif %}
{{ extra_server_args }} {{ extra_server_args }}