From c2ee32b71b0e6f5056716c7b3d5863073d2bcea2 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Mon, 21 Aug 2023 17:16:50 +0200 Subject: [PATCH] Add ability to define a config for journald At the moment we aim to make systemd-journald a universal destination for log files across services. With that there is currently no way of configuring journald using OSA. While this might be neat for production deployments, it's very valuable to have for CI as well. Change-Id: I70a8c9266cb12811a58f5a183955dbec319e539f (cherry picked from commit 65f28c5bb406980500f012cf0ad3320ddb69e2ed) --- defaults/main.yml | 2 ++ .../journald_config-e3b0e5060dd5f6e7.yaml | 5 +++++ tasks/main.yml | 7 +++++- tasks/openstack_hosts_systemd.yml | 22 +++++++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/journald_config-e3b0e5060dd5f6e7.yaml diff --git a/defaults/main.yml b/defaults/main.yml index c234cc76..157c8997 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -172,6 +172,8 @@ openstack_hosts_power_tool_enable: "{{ ('repo_all' in groups or 'manila_all' in # Keep a history of systemd journals on disk after reboots openstack_host_keep_journals: yes +# Define arbitrary configration for systemd-journald +openstack_hosts_journald_config: {} # Enable/Disable the yum fastestmirror plugin openstack_hosts_enable_yum_fastestmirror: yes diff --git a/releasenotes/notes/journald_config-e3b0e5060dd5f6e7.yaml b/releasenotes/notes/journald_config-e3b0e5060dd5f6e7.yaml new file mode 100644 index 00000000..ab95a116 --- /dev/null +++ b/releasenotes/notes/journald_config-e3b0e5060dd5f6e7.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Added variable ``openstack_host_journald_config`` that allows to supply + arbitrary configuration for systemd-journald as a mapping. diff --git a/tasks/main.yml b/tasks/main.yml index f4923fd3..8cb8c648 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -171,6 +171,11 @@ tags: - openstack_hosts-config - openstack_hosts-systemd - when: openstack_hosts_systemd_networkd_devices or openstack_hosts_systemd_networkd_networks or openstack_hosts_systemd_services or openstack_hosts_systemd_mounts + when: + - openstack_hosts_systemd_networkd_devices or + openstack_hosts_systemd_networkd_networks or + openstack_hosts_systemd_services or + openstack_hosts_systemd_mounts or + openstack_hosts_journald_config tags: - always diff --git a/tasks/openstack_hosts_systemd.yml b/tasks/openstack_hosts_systemd.yml index 2a027355..4110e89a 100644 --- a/tasks/openstack_hosts_systemd.yml +++ b/tasks/openstack_hosts_systemd.yml @@ -42,3 +42,25 @@ systemd_mounts: "{{ openstack_hosts_systemd_mounts }}" when: - openstack_hosts_systemd_mounts + +- name: Configure systemd-journald + when: openstack_hosts_journald_config + block: + - name: Create /etc/systemd/journald.conf.d directory + file: + path: /etc/systemd/journald.conf.d + state: directory + owner: root + group: systemd-journal + mode: "0755" + + - name: Define journald configuration + copy: + content: |- + [Journal] + {% for key, value in openstack_hosts_journald_config.items() %} + {{ key }}={{ value }} + {% endfor %} + dest: /etc/systemd/journald.conf.d/99-osa-journal.conf + notify: + - Restart systemd-journald