From 26b557ad452fe5015faa74d654076102edf4d80c Mon Sep 17 00:00:00 2001 From: Martin Vancl Date: Thu, 6 Oct 2022 10:50:18 +0200 Subject: [PATCH] add: custom config path; fix: add missing "become"; add: new platfoms versions --- README.md | 25 +++++++++++++++++++------ defaults/main.yml | 3 ++- handlers/main.yml | 1 + meta/main.yml | 8 +++++++- tasks/main.yml | 14 +++++++++++++- 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6bc7904..0b65a3c 100644 --- a/README.md +++ b/README.md @@ -6,16 +6,27 @@ The configuration options can be obtained from [journald.conf(5)](https://www.fr You can ask this role to wipe the persistent journal directory at `/var/log/journal`. Note that this changes journald's behaviour if the storage was set to `auto`. +To get the current systemd-journald running configuration run: `systemd-analyze cat-config systemd/journald.conf` + ## Requirements systemd with journald compiled in ## Role Variables -| Name | Default/Required | Description | -|----------------------------|:----------------:|--------------------------------------------------| -| `journald_config` | `{}` | Dict of configuration items for systemd-journald | -| `journald_wipe_persistent` | `false` | Wipe the persistent journal directory | +| Name | Default/Required | Description | +|----------------------------|:---------------------------------:|--------------------------------------------------| +| `journald_config` | `{}` / no | Dict of configuration items for systemd-journald | +| `journald_wipe_persistent` | `false` / no | Wipe the persistent journal directory | +| `journald_config_path` | `/etc/systemd/journald.conf` / no | Journald config file path | + + +| Configuration path | Description | +| ----------------------------------------- | ------------------------------------------------------------------------ | +| `/etc/systemd/journald.conf` | default/base configuration, as defined by the local system administrator | +| `/etc/systemd/journald.conf.d/*.conf` | local administrator override directory (filename is an arbitrary value) | +| `/run/systemd/journald.conf.d/*.conf` | runtime override directory (filename is an arbitrary value) | +| `/usr/lib/systemd/journald.conf.d/*.conf` | vendor package override directory | ## Dependencies @@ -26,13 +37,15 @@ None ```yml - hosts: all roles: - - systemd-journald + - stuvusit.systemd-journald + vars: journald_config: Storage: volatile RuntimeMaxUse: 1G ForwardToConsole: "yes" TTYPath: /dev/tty12 - journald_wipe_persistent: true + journald_wipe_persistent: True + journald_config_path: /etc/systemd/journald.conf.d/99-ansible.conf ``` ## License diff --git a/defaults/main.yml b/defaults/main.yml index 5be99bb..dc74759 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,3 +1,4 @@ --- journald_config: {} -journald_wipe_persistent: false +journald_wipe_persistent: False +journald_config_path: /etc/systemd/journald.conf diff --git a/handlers/main.yml b/handlers/main.yml index a3f5bd0..6e001ef 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,5 +1,6 @@ --- - name: Restart systemd-journald + become: True service: name: systemd-journald.service state: restarted diff --git a/meta/main.yml b/meta/main.yml index 04a8989..5fcc92f 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -10,11 +10,17 @@ galaxy_info: platforms: - name: Ubuntu versions: - - xenial - yakkety + - xenial + - bionic + - focal + - jammy - name: Debian versions: - jessie + - stretch + - buster + - bullseye - name: ArchLinux versions: - all diff --git a/tasks/main.yml b/tasks/main.yml index 08bd44a..f3ca86e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,14 +1,26 @@ --- +- name: Create journald config directory + become: True + file: + path: "{{ journald_config_path | dirname }}" + mode: 0755 + owner: root + group: root + recurse: True + notify: Restart systemd-journald + - name: Create journald configuration + become: True template: src: journald.conf.j2 - dest: /etc/systemd/journald.conf + dest: "{{ journald_config_path }}" mode: 0644 owner: root group: root notify: Restart systemd-journald - name: Wipe persistent journal directory + become: True file: path: /var/log/journal state: absent