Fix method undefined in heredoc

This commit is contained in:
2026-04-11 14:52:29 +04:00
parent a89db454d0
commit c92f9157a5
2 changed files with 5 additions and 10 deletions

View File

@@ -16,16 +16,19 @@ if primary.nil?
return
end
postgresql_service_name = "postgresql@#{postgresql_version}-main"
postgresql_data_dir = "/var/lib/postgresql/#{postgresql_version}/main"
# TODO Replace pg.kosmos.local with private IP once available
# via proper node attribute
# https://gitea.kosmos.org/kosmos/chef/issues/263
execute "set up replication" do
command <<-EOF
systemctl stop #{postgresql_service}
systemctl stop #{postgresql_service_name}
mv #{postgresql_data_dir} #{postgresql_data_dir}.old
pg_basebackup -h pg.kosmos.local -U replication -D #{postgresql_data_dir} -R
chown -R postgres:postgres #{postgresql_data_dir}
systemctl start #{postgresql_service}
systemctl start #{postgresql_service_name}
EOF
environment 'PGPASSWORD' => postgresql_data_bag_item['replication_password']
sensitive true