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 +}