Initial commit

This commit is contained in:
Sven Velt 2024-11-08 11:24:44 +01:00
commit 6c799f6dbc
8 changed files with 129 additions and 0 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
.*.swp
*~

35
README.md Normal file
View file

@ -0,0 +1,35 @@
# systemd-journald-size
Set maximum disk usage for systemd-journald
## Requirements
- systemd based Linux distribution with systemd-journald
## Role Variables
Defaults:
- `systemd_journald_size`: `100M`
## Dependencies
- None
## Example Playbook
- hosts: all
roles:
- role: systemd-journald-size
when: ansible_service_mgr == 'systemd'
## License
AGPL3.0-or-later
## Author Information
- Sven Velt <sven-ansiblerole@velt.biz>
- https://git.velt.biz/

3
defaults/main.yml Normal file
View file

@ -0,0 +1,3 @@
---
systemd_journald_size: 100M

10
handlers/main.yml Normal file
View file

@ -0,0 +1,10 @@
---
- name: Restart systemd-journald
service:
name: systemd-journald
state: restarted
- name: Vaccuum journald
command:
cmd: 'journalctl --vacuum-size={{ systemd_journald_size }}'

39
meta/main.yml Normal file
View file

@ -0,0 +1,39 @@
galaxy_info:
author: Sven Velt
description: Set maximum disk usage of systemd-journald
company: velt.biz
issue_tracker_url: https://git.velt.biz/Ansible/systemd-journald-size/issues
license: AGPL-3.0-or-later
min_ansible_version: 2.1
platforms:
- name: Debian
versions:
- stretch
- buster
- bullseye
- bookworm
- trixie
- name: Ubuntu
versions:
- bionic
- focal
- jammy
- noble
- name: Fedora
versions:
- 38
- 39
- 40
- 41
- name: EL
versions:
- 6
- 7
- 8
- 9
galaxy_tags:
- operations
dependencies: []

View file

@ -0,0 +1,7 @@
---
- hosts: all
roles:
- role: systemd-journald-size
when: ansible_service_mgr == 'systemd'

30
tasks/main.yml Normal file
View file

@ -0,0 +1,30 @@
---
- name: Check if systemd-journald is running
service_facts:
ignore_errors: true
register: systemd_journald_services
- name: '[BLOCK] When systemd-journald is running...'
when: systemd_journald_services is succeeded and "systemd-journald.service" in ansible_facts.services
block:
- name: Create /etc/systemd/journald.conf.d
file:
path: /etc/systemd/journald.conf.d
state: directory
owner: root
group: root
mode: 0755
- name: Template /etc/systemd/journald.conf.d/SystemMaxUse.conf
template:
src: SystemMaxUse.conf.j2
dest: /etc/systemd/journald.conf.d/SystemMaxUse.conf
owner: root
group: root
mode: 0755
backup: true
notify:
- Restart systemd-journald
- Vaccuum journald

View file

@ -0,0 +1,2 @@
[Journal]
SystemMaxUse={{ systemd_journald_size }}