From c48632c1667fa224b525284d8859eb1e8cae92ff Mon Sep 17 00:00:00 2001 From: "Zeno F. Pensky" Date: Tue, 17 Dec 2019 18:13:23 +0100 Subject: [PATCH] AdHoc (log rotate) Add feature for logrotation Magento logs should be rotated as they otherwise might grow realy large. This adds the logrotation, if an debian system is used. --- tasks/log-rotate.yml | 14 ++++++++++++++ tasks/main.yml | 1 + templates/logrotate.j2 | 9 +++++++++ 3 files changed, 24 insertions(+) create mode 100644 tasks/log-rotate.yml create mode 100644 templates/logrotate.j2 diff --git a/tasks/log-rotate.yml b/tasks/log-rotate.yml new file mode 100644 index 0000000..0ec2513 --- /dev/null +++ b/tasks/log-rotate.yml @@ -0,0 +1,14 @@ + +- name: Check if log rotation is installed + stat: + path: /etc/logrotate.d/ + register: log_rotate_stats + +- name: Add logrotation for magento logs + template: + src: "logrotate.j2" + dest: "/etc/logrotate.d/magento2" + owner: "root" + group: "root" + mode: "u=rw,g=r,o=r" + when: log_rotate_stats.stat.isdir \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index 76f8ab9..b260f7d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -5,3 +5,4 @@ - include: "message-queue-consumers.yml" - include: "cleanup-old-clones.yml" - include: "admin.yml" +- include: "log-rotate.yml" diff --git a/templates/logrotate.j2 b/templates/logrotate.j2 new file mode 100644 index 0000000..2ef7d03 --- /dev/null +++ b/templates/logrotate.j2 @@ -0,0 +1,9 @@ +{{ magento_app_root }}/var/log/*log { + weekly + rotate 12 + missingok + notifempty + compress + delaycompress +} +