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 +} +