Skip to content

Commit

Permalink
log2ram fixes
Browse files Browse the repository at this point in the history
* don't run install when installed, unless disabled first
* bump up size of RAM disk for logs; we were immediately way over the
  limit (see also azlux/log2ram#163)
* hide a warning about missing 'mail' cmd
  • Loading branch information
spthm committed May 27, 2023
1 parent 8ce87a6 commit 1741b04
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions roles/housekeeping/tasks/housekeeping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@
mode: 0644
notify: restart tmp.mount

- name: Limit /var/log/journal size
ansible.builtin.lineinfile:
path: /etc/systemd/journald.conf
regexp: 'SystemMaxUse='
line: SystemMaxUse=30M
notify: restart journald

- name: Install log2ram dependencies
ansible.builtin.apt:
name: "{{ log2ram_dep_packages }}"
Expand All @@ -75,16 +82,43 @@
dest: "{{ log2ram_dir }}"
version: "{{ log2ram_version }}"
depth: 1
register: log2ram_clone

- name: Check if log2ram installed
ansible.builtin.shell: systemctl status log2ram
register: log2ram_status
become: yes
failed_when: log2ram_status.rc > 4

- ansible.builtin.set_fact:
log2ram_installed: "{{ log2ram_status.rc != 4 }}"

- name: Disable log2ram
ansible.builtin.systemd:
name: log2ram
enabled: no
state: stopped
when: log2ram_clone.changed and log2ram_installed

- name: Install log2ram
ansible.builtin.command: "sh {{ log2ram_dir }}/install.sh"
ansible.builtin.command:
chdir: "{{ log2ram_dir }}"
cmd: "sh -e {{ log2ram_dir }}/install.sh"
when: not log2ram_installed

- name: Set log2ram reserved size in RAM
ansible.builtin.lineinfile:
path: /etc/log2ram.conf
regexp: "^SIZE="
line: "SIZE=50M"
notify: restart tmp.mount
line: "SIZE=100M"
notify: restart log2ram

- name: Set log2ram mailer off
ansible.builtin.lineinfile:
path: /etc/log2ram.conf
regexp: "^MAIL="
line: "MAIL=false"
notify: restart log2ram

- name: Set log2ram write to disk to weekly on Mondays
ansible.builtin.lineinfile:
Expand Down

0 comments on commit 1741b04

Please sign in to comment.