From e5c69ec894e4b81843eedf5eb528fd67ff0ae52e Mon Sep 17 00:00:00 2001 From: Xan Manning Date: Sat, 3 Apr 2021 20:42:44 +0100 Subject: [PATCH] Add cgroup checks --- tasks/validate/environment/remote/cgroups.yml | 15 +++++++++++++++ tasks/validate/pre-flight.yml | 10 +++++++++- vars/main.yml | 10 ++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tasks/validate/environment/remote/cgroups.yml diff --git a/tasks/validate/environment/remote/cgroups.yml b/tasks/validate/environment/remote/cgroups.yml new file mode 100644 index 0000000..b84cca3 --- /dev/null +++ b/tasks/validate/environment/remote/cgroups.yml @@ -0,0 +1,15 @@ +--- + +- name: Check if {{ cgroup.name }} cgroup is enabled + ansible.builtin.command: grep -E "^{{ cgroup.name }}\s+.*\s+1$" /proc/cgroups + failed_when: false + changed_when: false + register: k3s_check_cgroup_option + +- name: Fail if {{ cgroup.name }} cgroup is not enabled + ansible.builtin.assert: + that: + - k3s_check_cgroup_option.rc == 0 + fail_msg: | + {{ cgroup.name }} cgroup disabled. {{ cgroup.documentation }} + success_msg: "{{ cgroup.name }} cgroup enabled." diff --git a/tasks/validate/pre-flight.yml b/tasks/validate/pre-flight.yml index 2387ceb..cdad466 100644 --- a/tasks/validate/pre-flight.yml +++ b/tasks/validate/pre-flight.yml @@ -13,12 +13,20 @@ - not k3s_skip_validation - not k3s_skip_env_checks +- include_tasks: environment/remote/cgroups.yml + loop: "{{ k3s_cgroup_subsys }}" + loop_control: + loop_var: cgroup + when: + - not k3s_skip_validation + - not k3s_skip_env_checks + - include_tasks: environment/remote/packages.yml loop: "{{ k3s_check_packages }}" loop_control: loop_var: package when: - - k3s_skip_validation + - not k3s_skip_validation - not k3s_skip_env_checks - include_tasks: environment/local/issue-data.yml diff --git a/vars/main.yml b/vars/main.yml index dfb4c2e..6512c33 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -143,3 +143,13 @@ k3s_deprecated_config: - setting: docker correction: "docker: false" when: 1.20.0 + +k3s_cgroup_subsys: + - name: memory + documentation: | + If you are running on a Raspberry Pi, see: + https://rancher.com/docs/k3s/latest/en/advanced/#enabling-cgroups-for-raspbian-buster + - name: cpuset + documentation: | + If you are running Alpine Linux, see: + https://rancher.com/docs/k3s/latest/en/advanced/#additional-preparation-for-alpine-linux-setup