logcompress: configurable compression tool, default zstd

This commit is contained in:
Denis Knauf 2024-09-19 23:35:42 +02:00
parent 0ad6cbab1a
commit 6960f3797e
5 changed files with 23 additions and 2 deletions

View file

@ -1,3 +1,4 @@
---
has_hwrng: '{{ansible_virtualization_role != "guest" and ansible_local.devices.hwrng }}'
is_virt_guest: '{{ansible_virtualization_role == "guest"}}'
is_container: '{{ansible_virtualization_role == "guest" and ansible_virtualization_type == "lxc"}}'
@ -12,3 +13,4 @@ sshd_host_keys:
- '/etc/ssh/ssh_host_ed25519_key'
sshd_pubkey_authentication: 'yes'
apt_clean_after_install: false
logcompress_algo: 'zstd'

View file

@ -111,6 +111,7 @@
- vim-nox
- '{{ [] if is_container else ["xfsdump", "xfsprogs"] }}'
- '{{ needed_debs if needed_debs is defined else [] }}'
- '{{ logcompress_algo if logcompress_algo else [] }}'
# remove garbage:

View file

@ -55,6 +55,18 @@
with_fileglob:
- "systemd/system/*"
- name: install systemd-logcompress-jobs
template:
src: "{{item}}"
dest: /etc/systemd/system
owner: root
group: root
mode: 0644
with_fileglob:
- "systemd/system/*"
vars:
command: '{{ logcompress_command | default( logcompress_compression_commands[ logcompress_algo | default( "zstd") ] ) }}'
- name: enable services
systemd:
name: "{{item}}"

View file

@ -3,4 +3,4 @@ Description=Compress old logs in /var/log/%%Y
[Service]
Type=oneshot
ExecStart=/usr/bin/find /var/log/ -regex '/var/log/2[0-9][0-9][0-9]/2[0-9][0-9][0-9]-[01][0-9]-[0-3][0-9]' -mtime +0 -exec xz {} +
ExecStart=/usr/bin/find /var/log/ -regex '/var/log/2[0-9][0-9][0-9]/2[0-9][0-9][0-9]-[01][0-9]-[0-3][0-9]' -mtime +0 -exec {{command}} {} +

View file

@ -1,2 +1,8 @@
---
# vars file for system
logcompress_compression_commands:
gzip: 'gzip -9'
bzip2: 'bzip2 -9'
xz: 'xz -9'
lz4: 'lz4 -9 --rm'
zstd: 'zstd -19 --rm'