diff --git a/playbooks/roles/graphite/tasks/main.yaml b/playbooks/roles/graphite/tasks/main.yaml index bcedd75dc4..e78aea1ec0 100644 --- a/playbooks/roles/graphite/tasks/main.yaml +++ b/playbooks/roles/graphite/tasks/main.yaml @@ -53,3 +53,21 @@ name: - netcat state: present + +# Removes files not updated for ~9 months, and clears out empty directories +- name: Run periodic cleanup + cron: + name: "Graphite cleanup" + minute: "0" + hour: "2" + job: > + bash -c 'echo "--- $(date) ---"; + find /opt/graphite/storage/whisper -type f -mtime +270 -name "*.wsp" -delete -print; + find /opt/graphite/storage/whisper -depth -type d -empty -delete -print' + >> /var/log/graphite-cleanup.log 2>&1 + +- name: Rotate cleanup logs + include_role: + name: logrotate + vars: + logrotate_file_name: '/var/log/graphite-cleanup.log'