diff --git a/ansible/roles/mastodon/files/purge-media.sh b/ansible/roles/mastodon/files/purge-media.sh new file mode 100644 index 0000000..0a3ea7e --- /dev/null +++ b/ansible/roles/mastodon/files/purge-media.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -ex + +cd /opt/mastodon + +docker-compose exec mastodon tootctl media remove --days=7 +docker-compose exec mastodon tootctl statuses remove --days=7 +docker-compose exec mastodon tootctl preview_cards remove --days=7 +docker-compose exec mastodon tootctl cache clear diff --git a/ansible/roles/mastodon/tasks/main.yml b/ansible/roles/mastodon/tasks/main.yml index 4f3491c..ddd96c8 100644 --- a/ansible/roles/mastodon/tasks/main.yml +++ b/ansible/roles/mastodon/tasks/main.yml @@ -18,3 +18,21 @@ validate: docker-compose -f %s config notify: restart mastodon become: true + +- name: Install media cleanup script + template: + src: files/purge-media.sh + dest: /opt/mastodon/purge-media.sh + mode: "0755" + owner: "{{ docker_user.name }}" + become: true + +- name: Schedule media cleanup + cron: + name: clean up mastodon media + hour: 2 + minute: 0 + weekday: 1 + job: /opt/mastodon/purge-media.sh + user: "{{ docker_user.name }}" + become: true