WIP Prepare postgres for migration by replication
This commit is contained in:
50
site-cookbooks/kosmos_postgresql/recipes/replica_logical.rb
Normal file
50
site-cookbooks/kosmos_postgresql/recipes/replica_logical.rb
Normal file
@@ -0,0 +1,50 @@
|
||||
#
|
||||
# Cookbook:: kosmos_postgresql
|
||||
# Recipe:: replica_logical
|
||||
#
|
||||
|
||||
service postgresql_service do
|
||||
supports restart: true, status: true, reload: true
|
||||
end
|
||||
|
||||
postgresql_custom_server postgresql_version do
|
||||
role "replica_logical"
|
||||
end
|
||||
|
||||
postgresql_data_bag_item = data_bag_item('credentials', 'postgresql')
|
||||
|
||||
primary = postgresql_primary
|
||||
|
||||
if primary.nil?
|
||||
Chef::Log.warn("No PostgreSQL primary node found. Skipping replication setup.")
|
||||
return
|
||||
end
|
||||
|
||||
template "/usr/local/bin/pg_create_replication_subscriptions" do
|
||||
source "create_subscriptions.sh.erb"
|
||||
user "postgres"
|
||||
group "postgres"
|
||||
mode "0740"
|
||||
sensitive true
|
||||
end
|
||||
|
||||
cookbook_file "/usr/local/bin/pg_drop_replication_subscriptions" do
|
||||
source "drop_subscriptions.sh"
|
||||
user "postgres"
|
||||
group "postgres"
|
||||
mode "0744"
|
||||
end
|
||||
|
||||
cookbook_file "/usr/local/bin/pg_list_replication_subscriptions" do
|
||||
source "list_subscriptions.sh"
|
||||
user "postgres"
|
||||
group "postgres"
|
||||
mode "0744"
|
||||
end
|
||||
|
||||
cookbook_file "/usr/local/bin/pg_restore_all_databases" do
|
||||
source "restore_all_databases.sh"
|
||||
user "postgres"
|
||||
group "postgres"
|
||||
mode "0744"
|
||||
end
|
||||
Reference in New Issue
Block a user