diff --git a/README.md b/README.md index 81773296..5dc2e60b 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,8 @@ host. Previous settings will be lost, even if they are not specified in the role variables. Currently, this includes replacing at least the following configuration file: -* `/etc/kdump.conf` +* `/etc/kdump.conf` (RedHat like OS) +* `/etc/default/kdump-tools` (Ubuntu only, for now) ## Requirements @@ -97,6 +98,20 @@ re-execute the role after boot. Default: `false` +## Ubuntu + +To configure the default file-overwriting behavior, use for example: + +```yaml +kdump_kdump_tools: + USE_KDUMP: 1 + KDUMP_KERNEL: /var/lib/kdump/vmlinuz + KDUMP_INITRD: /var/lib/kdump/initrd.img + KDUMP_COREDIR: "/var/crash" + MAKEDUMP_ARGS: "-c -d 31" + KDUMP_FAIL_CMD: "reboot -f" +``` + ## Ansible Facts Returned by the Role **kdump_reboot_required**: The role sets this fact if the managed node requires diff --git a/handlers/main.yml b/handlers/main.yml index 0ebc60a8..aa89f704 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,7 +1,7 @@ --- - name: Restart kdump service: - name: kdump + name: "{{ __kdump_service }}" state: restarted when: - not __kdump_service_start.changed | d(false) diff --git a/tasks/main.yml b/tasks/main.yml index 8ab2c3b7..7205c23e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -11,7 +11,7 @@ - name: Ensure that kdump is enabled service: - name: kdump + name: "{{ __kdump_service }}" enabled: true - name: Include SSH tasks @@ -19,15 +19,15 @@ when: - kdump_target.type | d(none) == 'ssh' -- name: Get mode of /etc/kdump.conf if it exists +- name: Get mode of kdump configuration file if it exists stat: - path: /etc/kdump.conf + path: "{{ __kdump_conf_file }}" register: __kdump_conf -- name: Generate /etc/kdump.conf +- name: Generate kdump configuration file template: - src: kdump.conf.j2 - dest: /etc/kdump.conf + src: "{{ __kdump_conf_file | basename }}.j2" + dest: "{{ __kdump_conf_file }}" backup: true mode: "{{ __kdump_conf.stat.mode | d('0644') }}" notify: Restart kdump @@ -85,6 +85,6 @@ # to explicitly start kdump to rebuild initrd. - name: Ensure that kdump is started service: - name: kdump + name: "{{ __kdump_service }}" state: started register: __kdump_service_start diff --git a/templates/kdump-tools.j2 b/templates/kdump-tools.j2 new file mode 100644 index 00000000..c6223286 --- /dev/null +++ b/templates/kdump-tools.j2 @@ -0,0 +1,6 @@ +{{ ansible_managed | comment }} +{{ "system_role:kdump" | comment(prefix="", postfix="") }} + +{% for key, value in kdump_kdump_tools.items() %} +{{ key }} = {{ value }} +{% endfor %} diff --git a/vars/Ubuntu.yml b/vars/Ubuntu.yml new file mode 100644 index 00000000..69f5af8a --- /dev/null +++ b/vars/Ubuntu.yml @@ -0,0 +1,10 @@ +--- +__kdump_packages: + - iproute2 # for fact gathering for ip facts + - kexec-tools + - kdump-tools + - linux-crashdump + - openssh-client + +__kdump_conf_file: /etc/default/kdump-tools +__kdump_service: kdump-tools diff --git a/vars/main.yml b/vars/main.yml index 33a2af25..34927a4b 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -43,3 +43,7 @@ __kdump_is_rh_distro: "{{ ansible_distribution in __kdump_rh_distros }}" # Use this in conditionals to check if distro is Red Hat or clone, or Fedora __kdump_is_rh_distro_fedora: "{{ ansible_distribution in __kdump_rh_distros_fedora }}" # END - DO NOT EDIT THIS BLOCK - rh distros variables + +__kdump_service: kdump + +__kdump_conf_file: /etc/kdump.conf