From 750cc8afd4fff3e0f4f9078fe6a23e5c493fe6cb Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Tue, 8 Dec 2020 20:55:17 -0600 Subject: [PATCH] roles/logrotate: Install and enable logrotate Since Apache HTTPD does not have any built-in log rotation capability, we need `logrotate`. Somewhere along the line, the *logrotate* package stopped being installed by default. Additionally, with Fedora 30, it changed from including a drop-in file for (Ana)cron to providing a systemd timer unit. The *logrotate* role will ensure that the *logrotate* package is installed, and that the *logrotate.timer* service is enabled and running. This in turn will ensure that `logrotate` runs daily. Of course, since the systemd units were added in Fedora 30, machines to which this role is applied must be running at least that version. By listing the *logrotate* role as a dependency of the *httpd* role, we can ensure that `logrotate` manages the Apache error and access log files on any server that runs Apache HTTPD. --- roles/apache/meta/main.yml | 4 ++++ roles/logrotate/tasks/main.yml | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 roles/apache/meta/main.yml create mode 100644 roles/logrotate/tasks/main.yml diff --git a/roles/apache/meta/main.yml b/roles/apache/meta/main.yml new file mode 100644 index 0000000..24551fd --- /dev/null +++ b/roles/apache/meta/main.yml @@ -0,0 +1,4 @@ +dependencies: +- role: logrotate + tags: + - logrotate diff --git a/roles/logrotate/tasks/main.yml b/roles/logrotate/tasks/main.yml new file mode 100644 index 0000000..960c91b --- /dev/null +++ b/roles/logrotate/tasks/main.yml @@ -0,0 +1,19 @@ +- name: ensure logrotate is installed + package: + name: logrotate + state: present + tags: + - install + +- name: ensure logrotate timer unit is enabled + systemd: + name: logrotate.timer + enabled: true + tags: + - service +- name: ensure logrotate timer unit is started + systemd: + name: logrotate.timer + state: started + tags: + - service