Chapter 13. Configuring automatic crash dumps by using RHEL system roles
To manage kdump using Ansible, you can use the kdump
role, which is one of the RHEL system roles available in RHEL 9.
Using the kdump
role enables you to specify where to save the contents of the system’s memory for later analysis.
13.1. Configuring the kernel crash dumping mechanism by using the kdump
RHEL system role
Kernel crash dumping is a crucial feature for diagnosing and troubleshooting system issues. When your system encounters a kernel panic or other critical failure, crash kernel dumping allows you to capture a memory dump (core dump) of the kernel’s state at the time of the failure.
By using an Ansible playbook, you can set kernel crash dump parameters on multiple systems using the kdump
RHEL system role. This ensures consistent settings across all managed nodes for the kdump
service.
The kdump
system role replaces the content in the /etc/kdump.conf
and /etc/sysconfig/kdump
configuration files. Previous settings are changed to those specified in the role variables, and lost if they are not specified in the role variables.
Prerequisites
- You have prepared the control node and the managed nodes.
- You are logged in to the control node as a user who can run playbooks on the managed nodes.
-
The account you use to connect to the managed nodes has
sudo
permissions on them.
Procedure
Create a playbook file, for example
~/playbook.yml
, with the following content:Copy to Clipboard Copied! Toggle word wrap Toggle overflow --- - name: Configuring kernel crash dumping hosts: managed-node-01.example.com tasks: - name: Setting the kdump directory. ansible.builtin.include_role: name: redhat.rhel_system_roles.kdump vars: kdump_target: type: raw location: /dev/sda1 kdump_path: /var/crash/vmcore kernel_settings_reboot_ok: true
--- - name: Configuring kernel crash dumping hosts: managed-node-01.example.com tasks: - name: Setting the kdump directory. ansible.builtin.include_role: name: redhat.rhel_system_roles.kdump vars: kdump_target: type: raw location: /dev/sda1 kdump_path: /var/crash/vmcore kernel_settings_reboot_ok: true
The settings specified in the example playbook include the following:
kdump_target: <type_and_location>
-
Writes
vmcore
to a location other than the root file system. Thelocation
refers to a partition (by name, label, or UUID) when thetype
is raw or file system. kernel_settings_reboot_ok: <true|false>
-
The default is
false
. If set totrue
, the system role will determine if a reboot of the managed host is necessary for the requested changes to take effect and reboot it. If set tofalse
, the role will return the variablekernel_settings_reboot_required
with a value oftrue
, indicating that a reboot is required. In this case, a user must reboot the managed node manually.
For details about all variables used in the playbook, see the
/usr/share/ansible/roles/rhel-system-roles.kdump/README.md
file on the control node.Validate the playbook syntax:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ansible-playbook --syntax-check ~/playbook.yml
$ ansible-playbook --syntax-check ~/playbook.yml
Note that this command only validates the syntax and does not protect against a wrong but valid configuration.
Run the playbook:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ansible-playbook ~/playbook.yml
$ ansible-playbook ~/playbook.yml
Verification
Verify the kernel crash dump parameters:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ansible managed-node-01.example.com -m command -a 'grep crashkernel /proc/cmdline'
$ ansible managed-node-01.example.com -m command -a 'grep crashkernel /proc/cmdline'
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.kdump/README.md
file -
/usr/share/doc/rhel-system-roles/kdump/
directory