]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
infra: add log rotation support (containers)
authorGuillaume Abrioux <gabrioux@redhat.com>
Tue, 4 Aug 2020 23:47:04 +0000 (01:47 +0200)
committerGuillaume Abrioux <gabrioux@redhat.com>
Tue, 11 Aug 2020 13:03:20 +0000 (15:03 +0200)
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 <gabrioux@redhat.com>
roles/ceph-infra/tasks/main.yml
roles/ceph-infra/templates/logrotate.conf.j2 [new file with mode: 0644]

index 18d8aaf9743b08dc0d0f518f085d9b54561e8436..6b2409be58f864a0b8620f845a67aabbc83c4af6 100644 (file)
   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 (file)
index 0000000..c64d4e0
--- /dev/null
@@ -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
+}