Parcourir la source

Create more conservative logrotate configuration for Apache

Emmanuel Bouthenot il y a 9 ans
Parent
commit
089470ff57

+ 9 - 0
roles/webserver/tasks/apache2.yml

@@ -5,6 +5,15 @@
     update_cache: 'yes'
   when: with_apache2
 
+- name: 'Install logrotate configuration for Apache'
+  template:
+    src: 'logrotate/apache2.j2'
+    dest: '/etc/logrotate.d/apache2'
+    owner: 'root'
+    group: 'root'
+    mode: '0644'
+  when: with_apache2
+
 - name: 'Install SSL vhost configuration for Apache'
   template:
     src: 'apache2/vhost_ssl.j2'

+ 26 - 0
roles/webserver/templates/logrotate/apache2.j2

@@ -0,0 +1,26 @@
+{% if ansible_prolog -%}
+{% from 'templates/ansible/prolog.j2' import prolog with context %}
+{{ prolog() }}
+{% endif -%}
+/var/log/apache2/*.log {
+    daily
+    missingok
+    rotate 1000
+    dateext
+    dateyesterday
+    compress
+    delaycompress
+    notifempty
+    create 0640 www-data adm
+    sharedscripts
+    postrotate
+        if /etc/init.d/apache2 status > /dev/null ; then \
+            /etc/init.d/apache2 reload > /dev/null; \
+        fi;
+    endscript
+    prerotate
+        if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
+            run-parts /etc/logrotate.d/httpd-prerotate; \
+        fi; \
+    endscript
+}