From 6cce62850dbbf336413c02ce7bf2830fa556ea5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoha=C3=AF-Eliel=20BERREBY?= Date: Mon, 6 Apr 2020 17:58:02 +0200 Subject: [PATCH] dhcp: configure log rotation --- roles/isc-dhcp-server/tasks/main.yml | 16 +++++++++++++--- .../templates/logrotate.d/dhcp.j2 | 11 +++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 roles/isc-dhcp-server/templates/logrotate.d/dhcp.j2 diff --git a/roles/isc-dhcp-server/tasks/main.yml b/roles/isc-dhcp-server/tasks/main.yml index 269843e..2916941 100644 --- a/roles/isc-dhcp-server/tasks/main.yml +++ b/roles/isc-dhcp-server/tasks/main.yml @@ -16,11 +16,21 @@ mode: u=rwx,g=rx,a=rx state: directory -- name: Ensute rsyslog knows where to send dhcp logs +- name: Ensure rsyslog knows where to send dhcp logs lineinfile: path: /etc/rsyslog.conf - regexp: '^local7[.][*]' - line: "local7.* /var/log/dhcp/dhcpd.log" + line: "local7.* /var/log/dhcp/dhcpd.log" + +- name: Configure dhcp log rotation + template: + src: logrotate.d/dhcp.j2 + dest: /etc/logrotate.d/dhcp + mode: 0644 + +- name: restart rsyslog + systemd: + name: rsyslog + state: restarted - name: Configure /etc/default/isc-dhcp-server template: diff --git a/roles/isc-dhcp-server/templates/logrotate.d/dhcp.j2 b/roles/isc-dhcp-server/templates/logrotate.d/dhcp.j2 new file mode 100644 index 0000000..9823aed --- /dev/null +++ b/roles/isc-dhcp-server/templates/logrotate.d/dhcp.j2 @@ -0,0 +1,11 @@ +/var/log/dhcp/dhcpd.log { + # common options + daily + rotate 365 + missingok + compress + delaycompress + notifempty + + copytruncate +}