mirror of
https://github.com/k3s-io/k3s-ansible.git
synced 2025-12-25 00:12:37 +01:00
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:
@@ -3,6 +3,10 @@
|
|||||||
when: airgap_dir is defined
|
when: airgap_dir is defined
|
||||||
block:
|
block:
|
||||||
|
|
||||||
|
- name: Distribute Airgap Artifacts
|
||||||
|
tags:
|
||||||
|
- distribute_artifacts
|
||||||
|
block:
|
||||||
- name: Verify Ansible meets airgap version requirements.
|
- name: Verify Ansible meets airgap version requirements.
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "ansible_version.full is version_compare('2.12', '>=')"
|
that: "ansible_version.full is version_compare('2.12', '>=')"
|
||||||
@@ -93,6 +97,8 @@
|
|||||||
- "{{ airgap_dir }}/*.tar.zst"
|
- "{{ airgap_dir }}/*.tar.zst"
|
||||||
- "{{ airgap_dir }}/*.tar"
|
- "{{ airgap_dir }}/*.tar"
|
||||||
|
|
||||||
|
- name: Install Airgap K3s
|
||||||
|
block:
|
||||||
- name: Run K3s Install [server]
|
- name: Run K3s Install [server]
|
||||||
when: inventory_hostname in groups['server'] or ansible_host in groups['server']
|
when: inventory_hostname in groups['server'] or ansible_host in groups['server']
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
# noqa var-naming[no-role-prefix]
|
# noqa var-naming[no-role-prefix]
|
||||||
ansible.builtin.find:
|
ansible.builtin.find:
|
||||||
paths: "{{ systemd_dir }}"
|
paths: "{{ systemd_dir }}"
|
||||||
patterns: "k3s*.service"
|
patterns: "k3s*.service*"
|
||||||
register: k3s_service_files
|
register: k3s_service_files
|
||||||
|
|
||||||
- name: Save current K3s service
|
- name: Save current K3s service
|
||||||
@@ -33,16 +33,27 @@
|
|||||||
force: true
|
force: true
|
||||||
loop: "{{ k3s_service_files.files }}"
|
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
|
- name: Install new K3s Version
|
||||||
# For some reason, ansible-lint thinks using enviroment with command is an error
|
# 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
|
# even though its valid https://ansible.readthedocs.io/projects/lint/rules/inline-env-var/#correct-code
|
||||||
ansible.builtin.command: # noqa inline-env-var
|
ansible.builtin.command: # noqa inline-env-var
|
||||||
cmd: /usr/local/bin/k3s-install.sh
|
cmd: /usr/local/bin/k3s-install.sh
|
||||||
environment: >-
|
environment: >-
|
||||||
{{ extra_install_envs | combine({
|
{{ extra_install_envs
|
||||||
|
| combine({
|
||||||
"INSTALL_K3S_SKIP_START": "true",
|
"INSTALL_K3S_SKIP_START": "true",
|
||||||
"INSTALL_K3S_VERSION": k3s_version,
|
"INSTALL_K3S_VERSION": k3s_version,
|
||||||
}) }}
|
})
|
||||||
|
| combine(airgap_dir is defined and {"INSTALL_K3S_SKIP_DOWNLOAD": "true"} or {}) }}
|
||||||
changed_when: true
|
changed_when: true
|
||||||
|
|
||||||
- name: Restore K3s service
|
- name: Restore K3s service
|
||||||
|
|||||||
Reference in New Issue
Block a user