Add logrotate meta configuration for PSQL
- parametrize interval and rotate
Related: PROD-29848
Change-Id: I441d25ce44a3a46768f1dd9c9a04609f0eaf51c7
diff --git a/postgresql/meta/logrotate.yml b/postgresql/meta/logrotate.yml
new file mode 100644
index 0000000..bf6e1f6
--- /dev/null
+++ b/postgresql/meta/logrotate.yml
@@ -0,0 +1,26 @@
+## Default: Weekly rotation with 10 rotations kept
+{%- from "postgresql/map.jinja" import server, client with context %}
+
+{%- if server.get('enabled', False) %}
+ {%- set log_interval = server.get('logrotate', {}).get('interval', 'weekly') %}
+ {%- set log_rotation = server.get('logrotate', {}).get('rotate', 10) %}
+{%- elif client.get('enabled', False) %}
+ {%- set log_interval = client.get('logrotate', {}).get('interval', 'weekly') %}
+ {%- set log_rotation = client.get('logrotate', {}).get('rotate', 10) %}
+{%- endif %}
+
+{%- if server.get('enabled', False) or client.get('enabled', False) %}
+job:
+ postgresql-common:
+ - files:
+ - /var/log/postgresql/*.log
+ options:
+ - {{ log_interval }}
+ - rotate: {{ log_rotation }}
+ - missingok
+ - compress
+ - delaycompress
+ - copytruncate
+ - notifempty
+ - su root root
+{%- endif %}