---
- name: Ensure the persistent journal directory exists
  ansible.builtin.file:
    path: /var/log/journal
    state: directory
    owner: root
    group: systemd-journal
    mode: "2755"

- name: Ensure the journald drop-in directory exists
  ansible.builtin.file:
    path: /etc/systemd/journald.conf.d
    state: directory
    owner: root
    group: root
    mode: "0755"

- name: Configure journald storage and size caps
  ansible.builtin.template:
    src: journald.conf.j2
    dest: /etc/systemd/journald.conf.d/60-linux-baseline.conf
    owner: root
    group: root
    mode: "0644"
  notify: Restart journald
