fix(upgrade): Implement airgap support for the upgrade flow. (#465)

Signed-off-by: fch-aa <21101725+fch-aa@users.noreply.github.com>

---------

Signed-off-by: fch-aa <21101725+fch-aa@users.noreply.github.com>
Co-authored-by: fch-aa <21101725+fch-aa@users.noreply.github.com>
This commit is contained in:
fch-aa
2025-12-04 19:29:28 +01:00
committed by GitHub
parent f06b042aab
commit 3b34d679e5
2 changed files with 119 additions and 102 deletions

View File

@@ -3,6 +3,10 @@
when: airgap_dir is defined
block:
- name: Distribute Airgap Artifacts
tags:
- distribute_artifacts
block:
- name: Verify Ansible meets airgap version requirements.
ansible.builtin.assert:
that: "ansible_version.full is version_compare('2.12', '>=')"
@@ -93,6 +97,8 @@
- "{{ airgap_dir }}/*.tar.zst"
- "{{ airgap_dir }}/*.tar"
- name: Install Airgap K3s
block:
- name: Run K3s Install [server]
when: inventory_hostname in groups['server'] or ansible_host in groups['server']
ansible.builtin.command:

View File

@@ -21,7 +21,7 @@
# noqa var-naming[no-role-prefix]
ansible.builtin.find:
paths: "{{ systemd_dir }}"
patterns: "k3s*.service"
patterns: "k3s*.service*"
register: k3s_service_files
- name: Save current K3s service
@@ -33,16 +33,27 @@
force: true
loop: "{{ k3s_service_files.files }}"
- name: Stage airgap artifacts for upgrade
when: airgap_dir is defined
ansible.builtin.include_role:
name: airgap
tasks_from: main.yml
apply:
tags:
- distribute_artifacts
- name: Install new K3s Version
# 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
ansible.builtin.command: # noqa inline-env-var
cmd: /usr/local/bin/k3s-install.sh
environment: >-
{{ extra_install_envs | combine({
{{ extra_install_envs
| combine({
"INSTALL_K3S_SKIP_START": "true",
"INSTALL_K3S_VERSION": k3s_version,
}) }}
})
| combine(airgap_dir is defined and {"INSTALL_K3S_SKIP_DOWNLOAD": "true"} or {}) }}
changed_when: true
- name: Restore K3s service