Fix method undefined in heredoc
This commit is contained in:
@@ -39,13 +39,5 @@ class Chef
|
|||||||
def postgresql_version
|
def postgresql_version
|
||||||
node['kosmos_postgresql']['postgresql_version']
|
node['kosmos_postgresql']['postgresql_version']
|
||||||
end
|
end
|
||||||
|
|
||||||
def postgresql_service
|
|
||||||
"postgresql@#{postgresql_version}-main"
|
|
||||||
end
|
|
||||||
|
|
||||||
def postgresql_data_dir
|
|
||||||
"/var/lib/postgresql/#{postgresql_version}/main"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,16 +16,19 @@ if primary.nil?
|
|||||||
return
|
return
|
||||||
end
|
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
|
# TODO Replace pg.kosmos.local with private IP once available
|
||||||
# via proper node attribute
|
# via proper node attribute
|
||||||
# https://gitea.kosmos.org/kosmos/chef/issues/263
|
# https://gitea.kosmos.org/kosmos/chef/issues/263
|
||||||
execute "set up replication" do
|
execute "set up replication" do
|
||||||
command <<-EOF
|
command <<-EOF
|
||||||
systemctl stop #{postgresql_service}
|
systemctl stop #{postgresql_service_name}
|
||||||
mv #{postgresql_data_dir} #{postgresql_data_dir}.old
|
mv #{postgresql_data_dir} #{postgresql_data_dir}.old
|
||||||
pg_basebackup -h pg.kosmos.local -U replication -D #{postgresql_data_dir} -R
|
pg_basebackup -h pg.kosmos.local -U replication -D #{postgresql_data_dir} -R
|
||||||
chown -R postgres:postgres #{postgresql_data_dir}
|
chown -R postgres:postgres #{postgresql_data_dir}
|
||||||
systemctl start #{postgresql_service}
|
systemctl start #{postgresql_service_name}
|
||||||
EOF
|
EOF
|
||||||
environment 'PGPASSWORD' => postgresql_data_bag_item['replication_password']
|
environment 'PGPASSWORD' => postgresql_data_bag_item['replication_password']
|
||||||
sensitive true
|
sensitive true
|
||||||
|
|||||||
Reference in New Issue
Block a user