Skip to content

Commit

Permalink
add: custom config path; fix: add missing "become"; add: new platfoms…
Browse files Browse the repository at this point in the history
… versions
  • Loading branch information
tuxmartin committed Oct 6, 2022
1 parent b43fc0c commit 26b557a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 9 deletions.
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
journald_config: {}
journald_wipe_persistent: false
journald_wipe_persistent: False
journald_config_path: /etc/systemd/journald.conf
1 change: 1 addition & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- name: Restart systemd-journald
become: True
service:
name: systemd-journald.service
state: restarted
8 changes: 7 additions & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 26b557a

Please sign in to comment.