feat: add prevent downgrades check in k3s ansible

Signed-off-by: Devin Buhl <devin@buhl.casa>
This commit is contained in:
Devin Buhl committed 2024-01-30 14:33:16 -05:00
1 parent 19308f0783
commit ef563a4472
4 files changed
+23 -2

No files matched your search

@@ -22,6 +22,10 @@
k3s_server_manifests_templates: []
k3s_server_manifests_urls: []
- name: Prevent downgrades
when: k3s_installed.stat.exists
ansible.builtin.include_tasks: tasks/version-check.yaml
- name: Install Kubernetes
ansible.builtin.include_role:
name: xanmanning.k3s
@@ -1,5 +1,4 @@
---
# https://github.com/k3s-io/k3s/issues/1971
- name: Cruft
block:
- name: Cruft | Get list of custom manifests
@@ -0,0 +1,18 @@
---
- name: Version Check
block:
- name: Get deployed k3s version
ansible.builtin.command: k3s --version
register: k3s_version
changed_when: false
failed_when: false
- name: Extract k3s version
ansible.builtin.set_fact:
current_k3s_version: "{{ k3s_version.stdout | regex_replace('(?im)k3s version (?P<version>[a-z0-9\\.\\+]+).*\n.*', '\\g<version>') }}"
- name: Check if upgrades are allowed
ansible.builtin.assert:
that:
- "k3s_release_version is version(current_k3s_version, '>=')"
fail_msg: "Unable to upgrade k3s because the deployed version is higher than the one specified in the configuration"