From 9650436585a3c015976e283e7ca8c00c0e21251c Mon Sep 17 00:00:00 2001 From: Pavlo <582643+paulkarabilo@users.noreply.github.com> Date: Thu, 26 Feb 2026 22:04:16 +0200 Subject: [PATCH] fix: use correct variable for k3s old token for agents in upgrade.yml playbook (#513) Signed-off-by: paulkarabilo <582643+paulkarabilo@users.noreply.github.com> --- roles/k3s_upgrade/tasks/main.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/roles/k3s_upgrade/tasks/main.yml b/roles/k3s_upgrade/tasks/main.yml index fdc687f..7cd0d8c 100644 --- a/roles/k3s_upgrade/tasks/main.yml +++ b/roles/k3s_upgrade/tasks/main.yml @@ -62,6 +62,11 @@ | combine(airgap_dir is defined and {"INSTALL_K3S_SKIP_DOWNLOAD": "true"} or {}) }} changed_when: true + - name: Get the token from the first server + # noqa var-naming[no-role-prefix] + ansible.builtin.set_fact: + k3s_server_upgrade_old_token: "{{ hostvars[groups[server_group][0]].k3s_upgrade_old_token }}" + - name: Install new K3s Version [agent] # For some reason, ansible-lint thinks using enviroment with command is an error # even though its valid https://ansible.readthedocs.io/projects/lint/rules/inline-env-var/#correct-code @@ -80,7 +85,7 @@ INSTALL_K3S_SYSTEMD_DIR: "{{ systemd_dir }}" INSTALL_K3S_VERSION: "{{ k3s_version }}" INSTALL_K3S_EXEC: "agent --server https://{{ api_endpoint }}:{{ api_port }} {{ extra_agent_args }}" - K3S_TOKEN: "{{ token if token is defined else k3s_upgrade_old_token.stdout }}" + K3S_TOKEN: "{{ token if token is defined else k3s_server_upgrade_old_token.stdout }}" # We overrides the extra_install_envs with required keys from _base_envs on purpose _install_envs: "{{ extra_install_envs | default({}) | combine(_base_envs) }}" changed_when: true