From 7ecc69c96907111a0696e537fd542390bccbb72e Mon Sep 17 00:00:00 2001 From: chrisfu Date: Wed, 28 Jan 2026 14:35:29 -0800 Subject: [PATCH] Add preflight checks for cgroup kernel params in k3s setup - Ensure cgroup kernel parameters are present before k3s installation. - Introduce playbook changes to integrate cgroup prerequisites role. --- infrastructure/playbooks/site.yml | 7 +++++++ infrastructure/roles/k3s/tasks/main.yml | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/infrastructure/playbooks/site.yml b/infrastructure/playbooks/site.yml index c1bb82d..85bd562 100644 --- a/infrastructure/playbooks/site.yml +++ b/infrastructure/playbooks/site.yml @@ -23,6 +23,13 @@ - local_user - rsyslog +- name: K3s cgroup prerequisites + hosts: k3s_hosts + become: true + serial: 1 + roles: + - cgroups + - name: K3s Cluster Setup hosts: k3s_hosts become: true diff --git a/infrastructure/roles/k3s/tasks/main.yml b/infrastructure/roles/k3s/tasks/main.yml index e465e3e..428fc87 100644 --- a/infrastructure/roles/k3s/tasks/main.yml +++ b/infrastructure/roles/k3s/tasks/main.yml @@ -35,6 +35,16 @@ changed_when: false failed_when: rancher_mounted.rc != 0 +- name: Preflight - ensure cgroup kernel params are present + ansible.builtin.command: "cat /proc/cmdline" + register: k3s_proc_cmdline + changed_when: false + +- name: Fail if cgroup params are missing (reboot required) + ansible.builtin.fail: + msg: "Missing cgroup params in /proc/cmdline: {{ ['cgroup_memory=1', 'cgroup_enable=memory'] | reject('in', k3s_proc_cmdline.stdout) | list }}. Reboot required before k3s install." + when: (['cgroup_memory=1', 'cgroup_enable=memory'] | reject('in', k3s_proc_cmdline.stdout) | list) | length > 0 + - name: Guardrail - ensure rancher mountpoint is not on SD/rootfs ansible.builtin.command: "findmnt -n -o SOURCE {{ k3s_rancher_mountpoint | default('/var/lib/rancher') }}" register: rancher_source