11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/mimas/plugins/server/postgresql.rb', line 11
def configure_postgresql(sudo_user:)
ssh(self, user: sudo_user) do |session|
config_file_path = session.run "sudo -u postgres psql -AtXc 'SHOW config_file'", capture: true
config_dir = Pathname.new(config_file_path.strip).parent
config_files = find_files("postgresql/**/*.conf")
config_files = config_files.map do |path|
[ path, path.split("/postgresql/")[1] ]
end.to_h
tmp_dir = Pathname.new("/").join("tmp", "postgresql")
config_files.each do |file, destination|
destination_parent_folder = Pathname.new(destination).parent
session.run "mkdir -p #{tmp_dir.join(destination_parent_folder)}"
session.upload file, tmp_dir.join(destination)
end
session.run "sudo rsync --archive --recursive --chown=postgres:postgres #{tmp_dir.join("*")} #{config_dir}"
session.run "rm -rf #{tmp_dir}"
session.run "sudo systemctl restart postgresql"
end
end
|