Set up Redis VM, upgrade all cookbooks for Chef 18, major cleanup #496
@ -6,16 +6,14 @@ description 'Installs/Configures Mastodon'
|
|||||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||||
version '0.2.1'
|
version '0.2.1'
|
||||||
|
|
||||||
depends 'application'
|
|
||||||
depends 'application_git'
|
|
||||||
depends 'backup'
|
depends 'backup'
|
||||||
depends 'elasticsearch'
|
depends 'elasticsearch'
|
||||||
depends 'java'
|
depends 'java'
|
||||||
depends 'firewall'
|
depends 'firewall'
|
||||||
depends 'redisio'
|
depends 'redisio'
|
||||||
depends 'tor-full'
|
depends 'tor-full'
|
||||||
depends 'poise-ruby-build'
|
|
||||||
depends 'postgresql'
|
depends 'postgresql'
|
||||||
depends 'kosmos-nginx'
|
depends 'kosmos-nginx'
|
||||||
depends 'kosmos-nodejs'
|
depends 'kosmos-nodejs'
|
||||||
depends 'kosmos_postgresql'
|
depends 'kosmos_postgresql'
|
||||||
|
depends 'ruby_build'
|
||||||
|
@ -71,6 +71,15 @@ npm_package "yarn" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
ruby_version = "3.0.4"
|
ruby_version = "3.0.4"
|
||||||
|
# ruby_version = "3.2.2"
|
||||||
|
|
||||||
|
ruby_path = "/opt/ruby_build/builds/#{ruby_version}"
|
||||||
|
bundle_path = "#{ruby_path}/bin/bundle"
|
||||||
|
|
||||||
|
ruby_build_install 'v20230615'
|
||||||
|
ruby_build_definition ruby_version do
|
||||||
|
prefix_path ruby_path
|
||||||
|
end
|
||||||
|
|
||||||
execute "systemctl daemon-reload" do
|
execute "systemctl daemon-reload" do
|
||||||
command "systemctl daemon-reload"
|
command "systemctl daemon-reload"
|
||||||
@ -85,7 +94,7 @@ template "/lib/systemd/system/mastodon-web.service" do
|
|||||||
app_dir: mastodon_path,
|
app_dir: mastodon_path,
|
||||||
bind: bind_ip,
|
bind: bind_ip,
|
||||||
port: node["kosmos-mastodon"]["app_port"],
|
port: node["kosmos-mastodon"]["app_port"],
|
||||||
bundle_path: "/opt/ruby_build/builds/#{ruby_version}/bin/bundle"
|
bundle_path: bundle_path
|
||||||
notifies :run, "execute[systemctl daemon-reload]", :immediately
|
notifies :run, "execute[systemctl daemon-reload]", :immediately
|
||||||
notifies :restart, "service[mastodon-web]", :delayed
|
notifies :restart, "service[mastodon-web]", :delayed
|
||||||
end
|
end
|
||||||
@ -96,7 +105,7 @@ template "/lib/systemd/system/mastodon-sidekiq.service" do
|
|||||||
source "mastodon-sidekiq.systemd.service.erb"
|
source "mastodon-sidekiq.systemd.service.erb"
|
||||||
variables user: mastodon_user,
|
variables user: mastodon_user,
|
||||||
app_dir: mastodon_path,
|
app_dir: mastodon_path,
|
||||||
bundle_path: "/opt/ruby_build/builds/#{ruby_version}/bin/bundle",
|
bundle_path: bundle_path,
|
||||||
sidekiq_threads: node["kosmos-mastodon"]["sidekiq_threads"]
|
sidekiq_threads: node["kosmos-mastodon"]["sidekiq_threads"]
|
||||||
notifies :run, "execute[systemctl daemon-reload]", :immediately
|
notifies :run, "execute[systemctl daemon-reload]", :immediately
|
||||||
notifies :restart, "service[mastodon-sidekiq]", :delayed
|
notifies :restart, "service[mastodon-sidekiq]", :delayed
|
||||||
@ -108,7 +117,7 @@ template "/lib/systemd/system/mastodon-sidekiq-scheduler.service" do
|
|||||||
source "mastodon-sidekiq-scheduler.systemd.service.erb"
|
source "mastodon-sidekiq-scheduler.systemd.service.erb"
|
||||||
variables user: mastodon_user,
|
variables user: mastodon_user,
|
||||||
app_dir: mastodon_path,
|
app_dir: mastodon_path,
|
||||||
bundle_path: "/opt/ruby_build/builds/#{ruby_version}/bin/bundle",
|
bundle_path: bundle_path,
|
||||||
sidekiq_threads: 1
|
sidekiq_threads: 1
|
||||||
notifies :run, "execute[systemctl daemon-reload]", :immediately
|
notifies :run, "execute[systemctl daemon-reload]", :immediately
|
||||||
notifies :restart, "service[mastodon-sidekiq-scheduler]", :delayed
|
notifies :restart, "service[mastodon-sidekiq-scheduler]", :delayed
|
||||||
@ -126,34 +135,39 @@ template "/lib/systemd/system/mastodon-streaming.service" do
|
|||||||
notifies :restart, "service[mastodon-streaming]", :delayed
|
notifies :restart, "service[mastodon-streaming]", :delayed
|
||||||
end
|
end
|
||||||
|
|
||||||
application mastodon_path do
|
rails_env = node.chef_environment == "development" ? "development" : "production"
|
||||||
owner "mastodon"
|
deploy_env = {
|
||||||
group "mastodon"
|
# FIXME: /usr/bin was missing from PATH when running `yarn install`
|
||||||
|
"PATH" => "#{ruby_path}/bin:/usr/bin:$PATH",
|
||||||
|
"HOME" => mastodon_path,
|
||||||
|
"RAILS_ENV" => rails_env,
|
||||||
|
"NODE_ENV" => rails_env,
|
||||||
|
"SKIP_POST_DEPLOYMENT_MIGRATIONS" => "true"
|
||||||
|
}
|
||||||
|
|
||||||
# Take care of application restarts manually, in the git resource
|
git mastodon_path do
|
||||||
action_on_update false
|
|
||||||
|
|
||||||
environment "HOME" => mastodon_path,
|
|
||||||
"PATH" => "/opt/ruby_build/builds/#{ruby_version}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
|
|
||||||
|
|
||||||
ruby_runtime ruby_version do
|
|
||||||
provider :ruby_build
|
|
||||||
version ruby_version
|
|
||||||
end
|
|
||||||
|
|
||||||
git do
|
|
||||||
user mastodon_user
|
user mastodon_user
|
||||||
group mastodon_user
|
group mastodon_user
|
||||||
|
|
||||||
repository node["kosmos-mastodon"]["repo"]
|
repository node["kosmos-mastodon"]["repo"]
|
||||||
revision node["kosmos-mastodon"]["revision"]
|
revision node["kosmos-mastodon"]["revision"]
|
||||||
# Restart services on deployments
|
# Restart services on deployments
|
||||||
notifies :restart, "application[#{mastodon_path}]", :delayed
|
notifies :run, "execute[restart mastodon services]", :delayed
|
||||||
|
end
|
||||||
|
|
||||||
|
execute "restart mastodon services" do
|
||||||
|
command "true"
|
||||||
|
action :nothing
|
||||||
|
notifies :restart, "service[mastodon-web]", :delayed
|
||||||
|
notifies :restart, "service[mastodon-sidekiq]", :delayed
|
||||||
|
notifies :restart, "service[mastodon-sidekiq-scheduler]", :delayed
|
||||||
|
notifies :restart, "service[mastodon-streaming]", :delayed
|
||||||
end
|
end
|
||||||
|
|
||||||
mastodon_credentials = data_bag_item('credentials', 'mastodon')
|
mastodon_credentials = data_bag_item('credentials', 'mastodon')
|
||||||
|
|
||||||
template ".env.production" do
|
template "#{mastodon_path}/.env.#{rails_env}" do
|
||||||
source "env.production.erb"
|
source "env.erb"
|
||||||
mode "0640"
|
mode "0640"
|
||||||
owner mastodon_user
|
owner mastodon_user
|
||||||
group mastodon_user
|
group mastodon_user
|
||||||
@ -179,37 +193,37 @@ application mastodon_path do
|
|||||||
default_locale: node["kosmos-mastodon"]["default_locale"],
|
default_locale: node["kosmos-mastodon"]["default_locale"],
|
||||||
allowed_private_addresses: node["kosmos-mastodon"]["allowed_private_addresses"],
|
allowed_private_addresses: node["kosmos-mastodon"]["allowed_private_addresses"],
|
||||||
libre_translate_endpoint: node["kosmos-mastodon"]["libre_translate_endpoint"]
|
libre_translate_endpoint: node["kosmos-mastodon"]["libre_translate_endpoint"]
|
||||||
notifies :restart, "application[#{mastodon_path}]", :delayed
|
notifies :run, "execute[restart mastodon services]", :delayed
|
||||||
end
|
end
|
||||||
|
|
||||||
execute "bundle install" do
|
execute "bundle install" do
|
||||||
environment "HOME" => mastodon_path
|
environment deploy_env
|
||||||
user mastodon_user
|
user mastodon_user
|
||||||
cwd mastodon_path
|
cwd mastodon_path
|
||||||
command "/opt/ruby_build/builds/#{ruby_version}/bin/bundle install --without development,test --deployment"
|
command "bundle install --without development,test --deployment"
|
||||||
end
|
end
|
||||||
|
|
||||||
execute "yarn install" do
|
execute "yarn install" do
|
||||||
environment "HOME" => mastodon_path, "NODE_ENV" => "production"
|
environment deploy_env
|
||||||
user mastodon_user
|
user mastodon_user
|
||||||
cwd mastodon_path
|
cwd mastodon_path
|
||||||
command "yarn install --pure-lockfile"
|
command "yarn install --pure-lockfile"
|
||||||
end
|
end
|
||||||
|
|
||||||
execute 'rake db:migrate' do
|
execute "rake db:migrate" do
|
||||||
environment "RAILS_ENV" => "production", "HOME" => mastodon_path, "SKIP_POST_DEPLOYMENT_MIGRATIONS" => "true"
|
environment deploy_env
|
||||||
user mastodon_user
|
user mastodon_user
|
||||||
group mastodon_user
|
group mastodon_user
|
||||||
cwd mastodon_path
|
cwd mastodon_path
|
||||||
command "PATH=\"/opt/ruby_build/builds/#{ruby_version}/bin:$PATH\" bundle exec rake db:migrate"
|
command "bundle exec rake db:migrate"
|
||||||
end
|
end
|
||||||
|
|
||||||
execute 'rake assets:precompile' do
|
execute "rake assets:precompile" do
|
||||||
environment "RAILS_ENV" => "production", "HOME" => mastodon_path
|
environment deploy_env
|
||||||
user mastodon_user
|
user mastodon_user
|
||||||
group mastodon_user
|
group mastodon_user
|
||||||
cwd mastodon_path
|
cwd mastodon_path
|
||||||
command "PATH=\"/opt/ruby_build/builds/#{ruby_version}/bin:$PATH\" bundle exec rake assets:precompile"
|
command "bundle exec rake assets:precompile"
|
||||||
end
|
end
|
||||||
|
|
||||||
service "mastodon-web" do
|
service "mastodon-web" do
|
||||||
@ -227,9 +241,8 @@ application mastodon_path do
|
|||||||
service "mastodon-streaming" do
|
service "mastodon-streaming" do
|
||||||
action [:enable, :start]
|
action [:enable, :start]
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
firewall_rule 'mastodon_app' do
|
firewall_rule "mastodon_app" do
|
||||||
port node['kosmos-mastodon']['app_port']
|
port node['kosmos-mastodon']['app_port']
|
||||||
source "10.1.1.0/24"
|
source "10.1.1.0/24"
|
||||||
protocol :tcp
|
protocol :tcp
|
||||||
|
Loading…
x
Reference in New Issue
Block a user