Connect to the PostgreSQL primary server instead of localhost
Move the db and user creation to its own recipe Refs #186
This commit is contained in:
@@ -26,7 +26,6 @@
|
||||
|
||||
include_recipe "kosmos-nodejs"
|
||||
include_recipe "kosmos-redis"
|
||||
include_recipe "kosmos-postgresql"
|
||||
include_recipe "java"
|
||||
|
||||
elasticsearch_user 'elasticsearch'
|
||||
@@ -42,22 +41,11 @@ end
|
||||
|
||||
elasticsearch_service 'elasticsearch'
|
||||
|
||||
# TODO: Remove the condition once we have migrated mastodon to andromeda
|
||||
unless platform?('ubuntu') && node[:platform_version].to_f < 18.04
|
||||
postgresql_data_bag_item = data_bag_item('credentials', 'postgresql')
|
||||
|
||||
postgresql_user 'mastodon' do
|
||||
action :create
|
||||
password postgresql_data_bag_item['mastodon_user_password']
|
||||
end
|
||||
|
||||
postgresql_database 'mastodon' do
|
||||
owner 'mastodon'
|
||||
action :create
|
||||
end
|
||||
else
|
||||
postgresql_data_bag_item = {}
|
||||
end
|
||||
postgresql_data_bag_item = data_bag_item('credentials', 'postgresql')
|
||||
postgresql_primary_node = postgresql_primary
|
||||
postgresql_server = postgresql_primary_node[:ipaddress]
|
||||
# PostgreSQL is on the same server, connect through localhost
|
||||
postgresql_server = "localhost" if postgresql_primary_node[:hostname] == node[:hostname]
|
||||
|
||||
mastodon_path = node["kosmos-mastodon"]["directory"]
|
||||
|
||||
@@ -169,7 +157,8 @@ application mastodon_path do
|
||||
s3_region: "eu-west-1",
|
||||
vapid_private_key: mastodon_credentials['vapid_private_key'],
|
||||
vapid_public_key: mastodon_credentials['vapid_public_key'],
|
||||
db_pass: postgresql_data_bag_item['mastodon_user_password']
|
||||
db_pass: postgresql_data_bag_item['mastodon_user_password'],
|
||||
db_host: postgresql_server
|
||||
end
|
||||
|
||||
execute "bundle install" do
|
||||
@@ -214,18 +203,3 @@ application mastodon_path do
|
||||
action [:enable, :start]
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Backup
|
||||
#
|
||||
|
||||
unless node.chef_environment == "development"
|
||||
unless node["backup"]["postgresql"]["databases"].keys.include? 'mastodon'
|
||||
node.override["backup"]["postgresql"]["databases"]["mastodon"] = {
|
||||
username: "mastodon",
|
||||
password: postgresql_data_bag_item['mastodon_user_password']
|
||||
}
|
||||
end
|
||||
|
||||
include_recipe "backup"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user