From 29d4c42f809e223185a577c12157184c75b4e958 Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Wed, 5 Aug 2020 01:47:04 +0200 Subject: [PATCH] infra: add log rotation support (containers) This commit adds the log rotation support via logrotate in containerized deployments. Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1848388 Signed-off-by: Guillaume Abrioux (cherry picked from commit f1aa6cea21ca5423bb0404eae6437a19eaae2653) --- roles/ceph-infra/tasks/main.yml | 17 +++++++++++++++++ roles/ceph-infra/templates/logrotate.conf.j2 | 12 ++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 roles/ceph-infra/templates/logrotate.conf.j2 diff --git a/roles/ceph-infra/tasks/main.yml b/roles/ceph-infra/tasks/main.yml index 18d8aaf97..6b2409be5 100644 --- a/roles/ceph-infra/tasks/main.yml +++ b/roles/ceph-infra/tasks/main.yml @@ -17,3 +17,20 @@ include_tasks: setup_ntp.yml when: ntp_service_enabled | bool tags: configure_ntp + +- name: ensure logrotate is installed + package: + name: logrotate + state: present + register: result + until: result is succeeded + when: not is_atomic | bool + +- name: add logrotate configuration + template: + src: logrotate.conf.j2 + dest: /etc/logrotate.d/ceph + mode: "0644" + owner: root + group: root + when: containerized_deployment | bool \ No newline at end of file diff --git a/roles/ceph-infra/templates/logrotate.conf.j2 b/roles/ceph-infra/templates/logrotate.conf.j2 new file mode 100644 index 000000000..c64d4e03d --- /dev/null +++ b/roles/ceph-infra/templates/logrotate.conf.j2 @@ -0,0 +1,12 @@ +/var/log/ceph/*.log { + rotate 7 + daily + compress + sharedscripts + postrotate + killall -q -1 ceph-mon ceph-mgr ceph-mds ceph-osd ceph-fuse radosgw rbd-mirror || pkill -1 -x "ceph-mon|ceph-mgr|ceph-mds|ceph-osd|ceph-fuse|radosgw|rbd-mirror" || true + endscript + missingok + notifempty + su root root +}