From 4904ffbe65b9c474406307d3255d7ee1014c2edd Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Mon, 11 Dec 2023 10:38:21 +0200 Subject: [PATCH] Add more maintenance tasks as services --- manifests/init.pp | 103 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 99 insertions(+), 4 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index e82da23..b7437ba 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -505,8 +505,103 @@ class mastodon ( active => true, enable => true, } - # tootctl maintenance fix-duplicates - # tootctl media remove --days 180 - # tootctl media remove-orphans - # tootctl preview_cards remove --days 180 + $_timer_remove_media = @("EOT") + [Unit] + Description=Mastodon - Remove old media + + [Timer] + OnBootSec=24min + OnUnitActiveSec=1d + Unit=mastodon_remove_media.service + + [Install] + WantedBy=timers.target + | EOT + + $_service_remove_media = @("EOT") + [Service] + Type=simple + User=${mastodon_user} + WorkingDirectory=${mastodon_home}/live + Environment='RAILS_ENV=production' 'PATH=${mastodon_home}/.rbenv/shims:${mastodon_home}/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' + ExecStart=/opt/mastodon/live/bin/tootctl media remove --days 180 + + [Unit] + OnFailure=status_email_antoniodelgado@%n.service + | EOT + + systemd::timer { 'mastodon_remove_media.timer': + ensure => present, + timer_content => $_timer_remove_media, + service_unit => 'mastodon_remove_media.service', + service_content => $_service_remove_media, + active => true, + enable => true, + } + $_timer_remove_orphans = @("EOT") + [Unit] + Description=Mastodon - Remove orphans + + [Timer] + OnBootSec=24min + OnUnitActiveSec=1d + Unit=mastodon_remove_orphans.service + + [Install] + WantedBy=timers.target + | EOT + + $_service_remove_orphans = @("EOT") + [Service] + Type=simple + User=${mastodon_user} + WorkingDirectory=${mastodon_home}/live + Environment='RAILS_ENV=production' 'PATH=${mastodon_home}/.rbenv/shims:${mastodon_home}/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' + ExecStart=/opt/mastodon/live/bin/tootctl remove-orphans + + [Unit] + OnFailure=status_email_antoniodelgado@%n.service + | EOT + + systemd::timer { 'mastodon_remove_orphans.timer': + ensure => present, + timer_content => $_timer_remove_orphans, + service_unit => 'mastodon_remove_orphans.service', + service_content => $_service_remove_orphans, + active => true, + enable => true, + } + $_timer_remove_cards = @("EOT") + [Unit] + Description=Mastodon - Remove old media + + [Timer] + OnBootSec=24min + OnUnitActiveSec=1d + Unit=mastodon_remove_cards.service + + [Install] + WantedBy=timers.target + | EOT + + $_service_remove_cards = @("EOT") + [Service] + Type=simple + User=${mastodon_user} + WorkingDirectory=${mastodon_home}/live + Environment='RAILS_ENV=production' 'PATH=${mastodon_home}/.rbenv/shims:${mastodon_home}/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' + ExecStart=/opt/mastodon/live/bin/tootctl preview_cards remove --days 180 + + [Unit] + OnFailure=status_email_antoniodelgado@%n.service + | EOT + + systemd::timer { 'mastodon_remove_cards.timer': + ensure => present, + timer_content => $_timer_remove_cards, + service_unit => 'mastodon_remove_cards.service', + service_content => $_service_remove_cards, + active => true, + enable => true, + } }