diff --git a/roles/nginx/tasks/main.yml b/roles/nginx/tasks/main.yml index 0461f73..a397adf 100644 --- a/roles/nginx/tasks/main.yml +++ b/roles/nginx/tasks/main.yml @@ -70,15 +70,28 @@ group: "{{ ansible_wheel }}" when: ansible_os_family == "RedHat" -- name: Fix rotating access.log - ansible.builtin.lineinfile: +- name: Disable web logs from newsyslog + ansible.builtin.replace: path: /etc/newsyslog.conf - regexp: "^{{ item }}\\s" - line: |- - {{ '{:<40}'.format(item) }}644 7 * $D0 Z /var/run/nginx.pid - with_items: - - /var/www/logs/access.log - - /var/www/logs/error.log + regexp: "^/var/www/logs/" + replace: "#/var/www/logs/" + when: ansible_system == "OpenBSD" + +- name: Install logrotate script + ansible.builtin.copy: + dest: /usr/local/bin/nginx-logrotate + src: nginx-logrotate.sh + mode: "0755" + owner: root + group: "{{ ansible_wheel }}" + when: ansible_system == "OpenBSD" + +- name: Add logrotate cron job + ansible.builtin.cron: + name: nginx-logrotate + hour: "0" + minute: "0" + job: /usr/local/bin/nginx-logrotate when: ansible_system == "OpenBSD" - name: Enable nginx service