From d46e76fc4ba8e2974c9035abbee96ff8781f9035 Mon Sep 17 00:00:00 2001 From: Laurent Grawet Date: Fri, 22 Dec 2023 23:43:46 +0100 Subject: [PATCH] Configure logrotate for Debian --- .../ansible/roles/haproxy/tasks/logs.yml | 12 +++++-- .../templates/logrotate-debian.conf.j2 | 35 +++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 app/scripts/ansible/roles/haproxy/templates/logrotate-debian.conf.j2 diff --git a/app/scripts/ansible/roles/haproxy/tasks/logs.yml b/app/scripts/ansible/roles/haproxy/tasks/logs.yml index 635fdc1a..e7baf3c9 100644 --- a/app/scripts/ansible/roles/haproxy/tasks/logs.yml +++ b/app/scripts/ansible/roles/haproxy/tasks/logs.yml @@ -6,10 +6,18 @@ ignore_errors: yes notify: restart rsyslog -- name: Installing HAProxy conf for logrotate +- name: Installing HAProxy conf for logrotate on EL template: src: /var/www/haproxy-wi/app/scripts/ansible/roles/haproxy/templates/logrotate.conf.j2 dest: /etc/logrotate.d/haproxy.conf force: no when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') - ignore_errors: yes \ No newline at end of file + ignore_errors: yes + +- name: Installing HAProxy conf for logrotate on Debian + template: + src: /var/www/haproxy-wi/app/scripts/ansible/roles/haproxy/templates/logrotate-debian.conf.j2 + dest: /etc/logrotate.d/haproxy-roxy-wi + force: no + when: (ansible_facts['os_family'] == "Debian" or ansible_facts['os_family'] == 'Ubuntu') + ignore_errors: yes diff --git a/app/scripts/ansible/roles/haproxy/templates/logrotate-debian.conf.j2 b/app/scripts/ansible/roles/haproxy/templates/logrotate-debian.conf.j2 new file mode 100644 index 00000000..7d446f06 --- /dev/null +++ b/app/scripts/ansible/roles/haproxy/templates/logrotate-debian.conf.j2 @@ -0,0 +1,35 @@ +/var/log/haproxy/access.log { + daily + rotate 10 + missingok + notifempty + compress + sharedscripts + postrotate + [ ! -x /usr/lib/rsyslog/rsyslog-rotate ] || /usr/lib/rsyslog/rsyslog-rotate + endscript +} + +/var/log/haproxy/error.log { + daily + rotate 10 + missingok + notifempty + compress + sharedscripts + postrotate + [ ! -x /usr/lib/rsyslog/rsyslog-rotate ] || /usr/lib/rsyslog/rsyslog-rotate + endscript +} + +/var/log/haproxy/status.log { + daily + rotate 10 + missingok + notifempty + compress + sharedscripts + postrotate + [ ! -x /usr/lib/rsyslog/rsyslog-rotate ] || /usr/lib/rsyslog/rsyslog-rotate + endscript +}