diff --git a/pg-server.conf.template b/pg-server.conf.template new file mode 100644 index 0000000..ef89091 --- /dev/null +++ b/pg-server.conf.template @@ -0,0 +1,10 @@ +[pg-server] +conninfo = host={{ master_ip }} user={{ backup_user }} dbname=postgres password={{ backup_password }} +streaming_conninfo = host={{ master_ip }} user={{ backup_stream_user }} password={{ bcakup_stream_password }} +backup_method = postgres +archiver = off +streaming_archiver = on +slot_name = barman_slot +create_slot = auto + + diff --git a/pg_hba.template b/pg_hba.template new file mode 100644 index 0000000..e091b9f --- /dev/null +++ b/pg_hba.template @@ -0,0 +1,8 @@ +local all postgres peer +local all all peer +host all all 127.0.0.1/32 scram-sha-256 +host all all ::1/128 scram-sha-256 +host replication {{ replication_user }} 10.0.0.10/32 scram-sha-256 +host replication {{ replication_user }} 10.0.0.11/32 scram-sha-256 +host replication {{ backup_stream_user }} 10.0.0.12/32 scram-sha-256 +host all {{ backup_user }} 10.0.0.12/32 scram-sha-256 \ No newline at end of file diff --git a/postgresql.conf.template b/postgresql.conf.template new file mode 100644 index 0000000..adcad93 --- /dev/null +++ b/postgresql.conf.template @@ -0,0 +1,33 @@ + +data_directory = '/var/lib/postgresql/14/main' +hba_file = '/etc/postgresql/14/main/pg_hba.conf' +ident_file = '/etc/postgresql/14/main/pg_ident.conf' + + +listen_addresses = '*' +port = 5432 +max_connections = 100 + + +wal_level = replica +wal_log_hints = on +max_wal_senders = 10 +max_replication_slots = 10 +hot_standby = on +hot_standby_feedback = on + + +{% if inventory_hostname == 'sql-master' %} + primary_slot_name = 'standby_slot' +{% else %} + primary_conninfo = 'host={{ master_ip }} port=5432 user={{ replication_user }} password={{ replication_password }} application_name=standby1' + primary_slot_name = 'standby_slot' +{% endif %} + +{% if inventory_hostname == 'sql-master' %} + archive_mode = on + archive_command = '/bin/true' +{% endif %} + +wal_keep_size = 1024 +max_slot_wal_keep_size = 1024 \ No newline at end of file