Merge "Adding an ability to set arbitrary cipher for apache site."
diff --git a/README.rst b/README.rst
index 029d693..d01adf8 100644
--- a/README.rst
+++ b/README.rst
@@ -271,6 +271,17 @@
- mail01.example.com
- mail01
+Logrotate settings which allow you to rotate the logs in
+a random time in a given time interval. Time in seconds
+
+.. code-block:: yaml
+
+ apache:
+ server:
+ logrotate:
+ start_period: 600
+ end_period: 1200
+
More Information
================
diff --git a/apache/map.jinja b/apache/map.jinja
index ab062ec..8d89577 100644
--- a/apache/map.jinja
+++ b/apache/map.jinja
@@ -16,6 +16,10 @@
'www_dir': '/var/www',
'service_user': 'www-data',
'service_group': 'www-data',
+ 'logrotate': {
+ 'start_period': '1',
+ 'end_period': '3600',
+ },
},
'Arch': {
'pkgs': ['apache'],
@@ -75,6 +79,10 @@
'www_dir': '/var/www',
'service_user': 'www-data',
'service_group': 'www-data',
+ 'logrotate': {
+ 'start_period': '1',
+ 'end_period': '3600',
+ },
},
'xenial': {
'pkgs': ['apache2'],
@@ -93,6 +101,10 @@
'www_dir': '/var/www',
'service_user': 'www-data',
'service_group': 'www-data',
+ 'logrotate': {
+ 'start_period': '1',
+ 'end_period': '3600',
+ },
},
}, grain='oscodename', merge=salt['pillar.get']('apache:server'))) %}
diff --git a/apache/meta/logrotate.yml b/apache/meta/logrotate.yml
new file mode 100644
index 0000000..24135e6
--- /dev/null
+++ b/apache/meta/logrotate.yml
@@ -0,0 +1,22 @@
+{%- from "apache/map.jinja" import server with context %}
+job:
+ apache2:
+ - files:
+ - /var/log/apache2/*.log
+ options:
+ - daily
+ - missingok
+ - rotate: 14
+ - compress
+ - delaycompress
+ - notifempty
+ - sharedscripts
+ - prerotate:
+ RANDOM=$(( $(dd if=/dev/urandom bs=2 count=1 2> /dev/null | cksum | cut -d' ' -f1) % 32767 ));
+ RANDOM_START={{ server.logrotate.start_period }};
+ RANDOM_END={{ server.logrotate.end_period }};
+ RANGE=$(( $RANDOM_END - $RANDOM_START ));
+ RESULT=$(( $RANDOM % $RANGE));
+ RESULT=$(( $RESULT + $RANDOM_START ));
+ sleep $RESULT
+ - postrotate: "if /etc/init.d/apache2 status > /dev/null; then /etc/init.d/apache2 reload > /dev/null; fi"
\ No newline at end of file