Add logrotate meta configuration for Nginx
- parametrize interval and rotate
Related: PROD-29848
Change-Id: I33dfec38ef7e00d77836003973e14492fdde2e18
diff --git a/nginx/meta/logrotate.yml b/nginx/meta/logrotate.yml
new file mode 100644
index 0000000..09b7f3a
--- /dev/null
+++ b/nginx/meta/logrotate.yml
@@ -0,0 +1,22 @@
+## Default: Daily rotation with 28 rotations kept
+{%- from "nginx/map.jinja" import server with context %}
+
+{%- if server.get('enabled', False) %}
+job:
+ nginx:
+ - files:
+ - /var/log/nginx/*.log
+ options:
+ - {{ server.get('logrotate', {}).get('interval', 'daily') }}
+ - rotate: {{ server.get('logrotate', {}).get('rotate', 28) }}
+ - missingok
+ - compress
+ - delaycompress
+ - notifempty
+ - create 0640 www-data adm
+ - sharedscripts
+ - prerotate:
+ if [ -d /etc/logrotate.d/httpd-prerotate ]; then run-parts /etc/logrotate.d/httpd-prerotate; fi
+ - postrotate:
+ invoke-rc.d nginx rotate >/dev/null 2>&1
+{%- endif %}