Skip to content

Commit

Permalink
kdump
Browse files Browse the repository at this point in the history
  • Loading branch information
Baoquan He authored and larskarlitski committed Apr 28, 2017
0 parents commit 3e16ae0
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 0 deletions.
19 changes: 19 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2017 Red Hat, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

# Ansible Role: Kernel Crash Dump

An ansible role which configures kdump.

## Role Variables

**dump_target**: Can be specified to write vmcore to a location that is not in
the root file system. If `kind` is `raw` or a filesystem type, location points
to a partition (by device node name, label, or uuid). For example:

```yaml
dump_target:
kind: raw
location: /dev/sda1
```
or for an `ext4` filesystem:

```yaml
dump_target:
kind: ext4
location: "12e3e25f-534e-4007-a40c-e7e080a933ad"
```

If `kind` is `ssh`, location points to a server:
example:

```yaml
kind: ssh
location: [email protected]
```

Similarly for `nfs`, `location` points to an nfs server:

```yaml
kind: nfs
location: nfs.example.com
```

**path**: The path to which vmcore will be written. If `dump_target` is not
null, path is relative to that dump target. Otherwise, it must be an absolute
path in the root file system.

**core_collector**: A command to copy the vmcore. If null, uses `makedumpfile`
with options depending on the `target_type`.

**action**:
The action that is performed when dumping the core file fails. Can be
`reboot`, `halt`, `poweroff`, or `shell`.

## License

MIT
5 changes: 5 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
dump_target: null
path: /var/crash
core_collector: null
action: reboot
3 changes: 3 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: restart kdump
service: name=kdump state=restarted
12 changes: 12 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
galaxy_info:
author: Baoquan He <[email protected]>
description: Configure kdump
galaxy_tags: [ 'system', 'beta' ]
company: Red Hat, Inc.
license: MIT
min_ansible_version: 2.2
platforms:
- name: Fedora
versions: [ 24, 25 ]
- name: EL
versions: [ 6, 7 ]
17 changes: 17 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- name: Install kexec-tools
package: name=kexec-tools state=present

- name: Find out reserved memory for the crash kernel
command: cat /sys/kernel/kexec_crash_size
register: kexec_crash_size

- name: Generate /etc/kdump.conf
template: src=kdump.conf.j2 dest=/etc/kdump.conf backup=yes
when: kexec_crash_size.stdout|int > 0
notify: restart kdump

- name: Generate /etc/sysconfig/kdump
template: src=kdump.j2 dest=/etc/sysconfig/kdump backup=yes
when: kexec_crash_size.stdout|int > 0
notify: restart kdump
11 changes: 11 additions & 0 deletions templates/kdump.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# {{ ansible_managed }}
# Last modified: {{ ansible_date_time.date }} {{ ansible_date_time.time }}

{% if dump_target %}
{{dump_target.kind}} {{dump_target.location}}
{% endif %}
path {{path}}
{% if core_collector %}
core_collector {{core_collector}}
{% endif %}
default {{action}}
28 changes: 28 additions & 0 deletions templates/kdump.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# {{ ansible_managed }}
# Last modified: {{ ansible_date_time.date }} {{ ansible_date_time.time }}

{% if ansible_distribution == 'Fedora' or (ansible_distribution == 'RedHat' and ansible_distribution_version|int >= 7) %}

KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet"

KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 rootflags=nofail acpi_no_memhotplug transparent_hugepage=never"

{% elif ansible_distribution == 'RedHat' and ansible_distribution_version|int < 7 %}

KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off acpi_no_memhotplug"

MKDUMPRD_ARGS=""

KDUMP_BOOTDIR="/boot"

{% endif %}

KDUMP_KERNELVER=""

KDUMP_COMMANDLINE=""

KEXEC_ARGS=""

KDUMP_IMG="vmlinuz"

KDUMP_IMG_EXT=""
6 changes: 6 additions & 0 deletions test/test_default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

- name: Ensure that the rule runs with default parameters
hosts: all

roles:
- kdump

0 comments on commit 3e16ae0

Please sign in to comment.