From e07d13ee4eb4b8d617740b0fb6e66174429f2cfd Mon Sep 17 00:00:00 2001 From: Jiri Kyjovsky Date: Sat, 19 Apr 2025 19:06:25 +0200 Subject: [PATCH] copr: virtlogd rotate logs for hypervisors Configure virtlogd to rotate logs older than 30 days. The default config does not delete anything since we log to a lot of small files which are ignored by the max size to rotate in default virtlogd config. --- roles/copr/hypervisor/files/virtlogd.conf | 7 +++++++ roles/copr/hypervisor/handlers/main.yml | 5 +++++ roles/copr/hypervisor/tasks/main.yml | 11 +++++++++++ 3 files changed, 23 insertions(+) create mode 100644 roles/copr/hypervisor/files/virtlogd.conf create mode 100644 roles/copr/hypervisor/handlers/main.yml diff --git a/roles/copr/hypervisor/files/virtlogd.conf b/roles/copr/hypervisor/files/virtlogd.conf new file mode 100644 index 0000000000..cc577799d8 --- /dev/null +++ b/roles/copr/hypervisor/files/virtlogd.conf @@ -0,0 +1,7 @@ +# We log each WM that has beed spawned to a log and once it shuts down +# the log is closed and we keep that small log. New machines logs their +# output to new file. So this way we keep the small logs of each WM +# for 30 days. +max_age_days = 30 + +log_root = "/var/log/libvirt/qemu" diff --git a/roles/copr/hypervisor/handlers/main.yml b/roles/copr/hypervisor/handlers/main.yml new file mode 100644 index 0000000000..a49f9f601c --- /dev/null +++ b/roles/copr/hypervisor/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: Reload virtlogd + ansible.builtin.service: + name: virtlogd + state: reloaded diff --git a/roles/copr/hypervisor/tasks/main.yml b/roles/copr/hypervisor/tasks/main.yml index d9868be37e..bbeac055be 100644 --- a/roles/copr/hypervisor/tasks/main.yml +++ b/roles/copr/hypervisor/tasks/main.yml @@ -200,3 +200,14 @@ provision_directory: /home/copr/provision provision_user: copr tags: always + +- name: Deploy virtlogd.conf + ansible.builtin.copy: + src: virtlogd.conf + dest: /etc/libvirt/virtlogd.conf + owner: root + group: root + mode: '0644' + notify: Reload virtlogd + tags: + - config