From 4ea7833055599ef57d4cb831fd9ee6baf4adb323 Mon Sep 17 00:00:00 2001 From: Jose Date: Sun, 15 Feb 2026 08:36:22 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor=20ker?= =?UTF-8?q?nel=20panic=20configuration=20with=20ansible.posix.sysctl=20for?= =?UTF-8?q?=20better=20management=20and=20readability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This refactoring involves updating the kernel panic configuration management to utilize the `ansible.posix.sysctl` module. This change enhances the clarity and maintainability of the code by providing a more structured approach to handling system settings. --- tasks/kernel.yml | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/tasks/kernel.yml b/tasks/kernel.yml index d8a23c5..de7fe63 100644 --- a/tasks/kernel.yml +++ b/tasks/kernel.yml @@ -3,16 +3,12 @@ # Configure kernel panic behavior # ------------------------------------------------- - name: kernel | Configure kernel panic auto-reboot - ansible.builtin.copy: - dest: /etc/sysctl.d/99-kernelpanic.conf - content: | - kernel.panic = 10 - kernel.panic_on_oops = 1 - owner: root - group: root - mode: '0644' - -- name: kernel | Apply kernel panic settings - ansible.builtin.command: - cmd: sysctl -p /etc/sysctl.d/99-kernelpanic.conf - become: true + ansible.posix.sysctl: + name: "{{ item.key }}" + value: "{{ item.value }}" + state: present + sysctl_file: /etc/sysctl.d/99-kernelpanic.conf + reload: yes + loop: + - { key: 'kernel.panic', value: '10' } + - { key: 'kernel.panic_on_oops', value: '1' }