Chapter 15. 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 8. Using the kdump role enables you to specify where to save the contents of the system's memory for later analysis. 15.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. Warning The kdump system role replaces the content in the /etc/kdump.conf and /etc/sysconfig/kdump configuration files. 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: --- - name: Configuring kernel crash dumping hosts: managed-node-01.example.com tasks: - name: Setting the kdump directory. ansible.builtin.include_role: name: 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. The location refers to a partition (by name, label, or UUID) when the type is raw or file system. kernel_settings_reboot_ok: <true|false> The default is false . If set to true , 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 to false , the role will return the variable kernel_settings_reboot_required with a value of true , 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: Note that this command only validates the syntax and does not protect against a wrong but valid configuration. Run the playbook: Verification Verify the kernel crash dump parameters: Additional resources /usr/share/ansible/roles/rhel-system-roles.kdump/README.md file /usr/share/doc/rhel-system-roles/kdump/ directory

Commands:
--- - name: Configuring kernel crash dumping hosts: managed-node-01.example.com tasks: - name: Setting the kdump directory. ansible.builtin.include_role: name: rhel-system-roles.kdump vars: kdump_target: type: raw location: /dev/sda1 kdump_path: /var/crash/vmcore kernel_settings_reboot_ok: true
ansible-playbook --syntax-check ~/playbook.yml
ansible-playbook ~/playbook.yml
ansible managed-node-01.example.com -m command -a 'grep crashkernel /proc/cmdline'