---

- name: Core Pattern - Create the directory for coredump files
  become: yes
  file:
    path: "{{ coredump_dir }}"
    state: directory
    mode: 0777

- name: Core Pattern - Disable apport (so it doesn't rewrite core_pattern on boot).
  become: yes
  copy:
    content: "enabled=0"
    dest: /etc/default/apport

- name: Core Pattern - Set /proc/sys/kernel/core_pattern.
  become: yes
  sysctl:
    name: "kernel.core_pattern"
    value: "{{ coredump_dir }}/{{ coredump_pattern }}"
    sysctl_set: yes
    state: present
    reload: yes
