Upgrade Mastodon from 4.3 to 4.7, deploy on new Ubuntu 24.04 VM #681

Merged
raucao merged 21 commits from chore/upgrade_mastodon into master 2026-10-08 13:02:46 +00:00
Showing only changes of commit 8a11cd88f7 - Show all commits
@@ -214,18 +214,26 @@ execute "rake db:migrate (post-deployment)" do
command "bundle exec rake db:migrate"
timeout 21_600
action :nothing
notifies :run, "execute[tootctl search deploy accounts mapping]", :immediately
notifies :run, "execute[tootctl search deploy (create indices)]", :immediately
end
# Mastodon 4.4 changed the Elasticsearch `accounts` index mappings
execute "tootctl search deploy accounts mapping" do
# Create or upgrade the Elasticsearch indices and mappings without importing
# data, so that search does not fail on a missing index. The (potentially very
# long) import is deferred to a systemd unit started in the background below.
execute "tootctl search deploy (create indices)" do
environment deploy_env
user mastodon_user
group mastodon_user
cwd mastodon_path
command "#{bundle_path} exec bin/tootctl search deploy --only-mapping --only=accounts"
command "#{bundle_path} exec bin/tootctl search deploy --no-import"
timeout 3_600
action :nothing
notifies :run, "execute[start mastodon search deploy]", :immediately
end
execute "start mastodon search deploy" do
command "systemctl start --no-block mastodon-search-deploy.service"
action :nothing
end
service "mastodon-web" do
@@ -282,6 +290,30 @@ systemd_unit 'mastodon-delete-old-media-cache.timer' do
action [:create, :enable, :start]
end
#
# Populate the Elasticsearch indices in the background. The indices and
# mappings are created synchronously by the recipe above; this unit only does
# the (potentially very long) import, so it is started without blocking.
#
systemd_unit 'mastodon-search-deploy.service' do
content({
Unit: {
Description: 'Populate the Mastodon search index'
},
Service: {
Type: "oneshot",
User: mastodon_user,
WorkingDirectory: mastodon_path,
Environment: "RAILS_ENV=#{rails_env}",
ExecStart: "#{bundle_path} exec bin/tootctl search deploy",
TimeoutStartSec: "21600",
}
})
triggers_reload true
action [:create]
end
firewall_rule "mastodon_app" do
port node['kosmos-mastodon']['app_port']
source "10.1.1.0/24"