2023-02-07 23:39:20 +00:00
# Patroni common options
2023-07-11 14:27:48 +00:00
patroni_version : "3.0.3"
2023-03-29 20:49:37 +00:00
patroni_install_official_repo : true
2023-02-07 23:39:20 +00:00
# Patroni cluster options
patroni_cluster_name : "patroni-cluster"
patroni_namespace : "/service/"
# Patroni PostgreSQL common options
2023-05-11 16:41:36 +00:00
patroni_postgresql_version : "15.3"
2023-02-20 12:08:07 +00:00
patroni_postgresql_install_repo : true
2023-03-29 20:49:37 +00:00
patroni_postgresql_system_locale : "en_US.UTF-8"
patroni_postgresql_system_language : "{{ patroni_postgresql_system_locale }}"
2023-02-07 23:39:20 +00:00
# Patroni superuser auth
patroni_superuser_username : "postgres"
patroni_superuser_password : "postgres"
# Patroni replication auth
patroni_replication_username : "replicator"
patroni_replication_password : "replicator"
# Patroni REST API options
patroni_restapi_username : "admin"
patroni_restapi_password : "admin"
patroni_restapi_listen_port : 8008
# Patroni SSL options
2023-02-20 12:08:07 +00:00
patroni_ssl : false
2023-02-07 23:39:20 +00:00
patroni_ssl_path : "/etc/patroni/ssl"
2023-02-20 12:08:07 +00:00
patroni_self_signed_cert : false
2023-02-07 23:39:20 +00:00
patroni_self_signed_cert_name : "cert"
2023-03-29 20:49:37 +00:00
patroni_play_group : "patroni"
2023-02-07 23:39:20 +00:00
## DCS options. Consul or Etcd
2023-02-20 12:08:07 +00:00
patroni_dcs_exists : false
2023-02-07 23:39:20 +00:00
patroni_dcs_type : "consul"
2023-07-03 21:00:54 +00:00
## Backup and restore options
2023-02-20 12:08:07 +00:00
patroni_wal_g_install : false
2023-07-03 21:00:54 +00:00
patroni_wal_g_pg_binary_name : 'wal-g-pg'
patroni_postgresql_archive_mode : "{{ 'on' if patroni_wal_g_install else 'off' }}"
patroni_postgresql_archive_command : "{{ 'http_proxy=' ~ wal_g_http_proxy ~ ' ' if wal_g_http_proxy is defined else '' }}{{ 'https_proxy=' ~ wal_g_https_proxy ~ ' ' if wal_g_https_proxy is defined else 'https_proxy=' ~ wal_g_http_proxy ~ ' ' if wal_g_http_proxy is defined else '' }}{{ wal_g_pg_binary_name ~ ' wal-push %p' if patroni_wal_g_install else '' }}"
2023-03-29 20:49:37 +00:00
2023-07-03 21:00:54 +00:00
patroni_wal_g_create_replica_methods :
- {option : "command" , value : "{{ 'http_proxy=' ~ wal_g_http_proxy ~ ' ' if wal_g_http_proxy is defined else '' }}{{ 'https_proxy=' ~ wal_g_https_proxy ~ ' ' if wal_g_https_proxy is defined else 'https_proxy=' ~ wal_g_http_proxy ~ ' ' if wal_g_http_proxy is defined else '' }}{{ wal_g_pg_binary_name }} backup-fetch {{ patroni_postgresql_data_dir }} LATEST" }
- {option : "no_params" , value : "True" }
patroni_basebackup_create_replica_methods :
- {option : "max-rate" , value : "1000M" }
- {option : "checkpoint" , value : "fast" }
# "restore_command" written to recovery.conf when configuring follower (create replica)
patroni_postgresql_restore_command : "{{ 'http_proxy=' ~ wal_g_http_proxy ~ ' ' if wal_g_http_proxy is defined else '' }}{{ 'https_proxy=' ~ wal_g_https_proxy ~ ' ' if wal_g_https_proxy is defined else 'https_proxy=' ~ wal_g_http_proxy ~ ' ' if wal_g_http_proxy is defined else '' }}{{ wal_g_pg_binary_name ~ ' wal-fetch %f %p' if patroni_wal_g_install else '' }}"
2023-05-19 08:58:42 +00:00
patroni_synchronous_mode : false # or 'true' for enable synchronous database replication
patroni_synchronous_mode_strict : false # if 'true' then block all client writes to the master, when a synchronous replica is not available
patroni_synchronous_node_count : 2 # number of synchronous standby databases
patroni_postgresql_port : "5432"
patroni_postgresql_encoding : "UTF8" # for bootstrap only (initdb)
patroni_postgresql_locale : "en_US.UTF-8" # for bootstrap only (initdb)
patroni_postgresql_data_checksums : true # for bootstrap only (initdb)
patroni_postgresql_password_encryption_algorithm : "scram-sha-256"
patroni_postgresql_unix_socket_dir : "/var/run/postgresql"
patroni_postgresql_stats_temp_directory_path : "/var/lib/pgsql_stats_tmp"
patroni_postgresql_use_pg_rewind : true # or 'false'
# try to use pg_rewind on the former leader when it joins cluster as a replica.
patroni_remove_data_directory_on_rewind_failure: false # or 'true' (if use_pg_rewind : 'true' )
# avoid removing the data directory on an unsuccessful rewind
# if 'true', Patroni will remove the PostgreSQL data directory and recreate the replica.
patroni_remove_data_directory_on_diverged_timelines : false # or 'true'
# if 'true', Patroni will remove the PostgreSQL data directory and recreate the replica
# if it notices that timelines are diverging and the former master can not start streaming from the new master.
# https://patroni.readthedocs.io/en/latest/replica_bootstrap.html#bootstrap
2023-06-13 18:30:54 +00:00
patroni_cluster_bootstrap_method : "initdb --username {{ patroni_superuser_username }}" # or "wal-g", "pgbackrest", "pg_probackup"
2023-05-19 08:58:42 +00:00
# https://patroni.readthedocs.io/en/latest/replica_bootstrap.html#building-replicas
patroni_create_replica_methods :
# - pgbackrest
# - wal_g
# - pg_probackup
- basebackup
# Dynamic configuration
patroni_postgresql_dynamic_parameters : {}
2023-07-03 21:00:54 +00:00
patroni_postgresql_backup_parameters :
postgresql :
parameters :
archive_command : "{{ patroni_postgresql_archive_command if patroni_wal_g_install else 'cd .' }}"
restore_command : "{{ patroni_postgresql_restore_command if patroni_wal_g_install else 'cd .' }}"
archive_mode : "on"
archive_timeout : "1800s"
2023-05-19 08:58:42 +00:00
# postgresql parameters to bootstrap dcs (are parameters for example)
patroni_postgresql_default_parameters :
max_connections : "1000"
superuser_reserved_connections : "5"
password_encryption : "{{ patroni_postgresql_password_encryption_algorithm }}"
max_locks_per_transaction : "64"
max_prepared_transactions : "0"
huge_pages : "try"
shared_buffers : "{{ (ansible_memory_mb.real.total * 0.25) | round | int }}MB"
max_worker_processes : "{{ ansible_processor_vcpus }}"
max_parallel_workers : "{{ ansible_processor_vcpus }}"
max_parallel_workers_per_gather : "{{ (ansible_processor_vcpus / 2) | round | int }}"
max_parallel_maintenance_workers : "{{ (ansible_processor_vcpus / 2) | round | int }}"
work_mem : "128MB"
maintenance_work_mem : "256MB"
effective_cache_size : "4GB"
checkpoint_timeout : "15min"
checkpoint_completion_target : "0.9"
min_wal_size : "2GB"
max_wal_size : "8GB"
wal_buffers : "32MB"
default_statistics_target : "1000"
seq_page_cost : "1"
random_page_cost : "4"
effective_io_concurrency : "2"
synchronous_commit : "on"
autovacuum : "on"
autovacuum_max_workers : "5"
autovacuum_vacuum_scale_factor : "0.01"
autovacuum_analyze_scale_factor : "0.01"
autovacuum_vacuum_cost_limit : "500"
autovacuum_vacuum_cost_delay : "2"
autovacuum_naptime : "1s"
max_files_per_process : "4096"
wal_level : "replica"
wal_keep_size : "2GB"
max_wal_senders : "10"
max_replication_slots : "10"
hot_standby : "on"
wal_log_hints : "on"
wal_compression : "on"
shared_preload_libraries : "pg_stat_statements,auto_explain"
pg_stat_statements.max : "10000"
pg_stat_statements.track : "all"
pg_stat_statements.track_utility : "false"
pg_stat_statements.save : "true"
auto_explain.log_min_duration : "10s"
auto_explain.log_analyze : "true"
auto_explain.log_buffers : "true"
auto_explain.log_timing : "false"
auto_explain.log_triggers : "true"
auto_explain.log_verbose : "true"
auto_explain.log_nested_statements : "true"
track_io_timing : "on"
log_lock_waits : "on"
log_temp_files : "0"
track_activities : "on"
track_counts : "on"
track_functions : "all"
log_checkpoints : "on"
logging_collector : "on"
log_truncate_on_rotation : "on"
log_rotation_age : "1d"
log_rotation_size : "0"
log_filename : "'postgresql-%a.log'"
log_line_prefix : "'%t [%p-%l] %r %q%u@%d '"
log_directory : "{{ patroni_postgresql_log_dir }}"
hot_standby_feedback : "on"
max_standby_streaming_delay : "30s"
wal_receiver_status_interval : "10s"
idle_in_transaction_session_timeout : "10min"
jit : "off"
# archive_command: 'wal-g wal-push %p'
# archive_command: 'pgbackrest --stanza={{ pgbackrest_stanza }} archive-push %p'
# max_worker_processes: '24'
# max_parallel_workers: '12'
# max_parallel_workers_per_gather: '2'
# max_parallel_maintenance_workers: '2'
# old_snapshot_threshold: '60min'
# list of lines that Patroni will use to generate pg_ident.conf
patroni_postgresql_pg_ident : [ ]
# - {mapname: "main", system_username: "postgres", pg_username: "backup"}
# - {mapname: "", system_username: "", pg_username: ""}
# Extended variables (optional)
patroni_ttl : 30
patroni_loop_wait : 10
patroni_retry_timeout : 10
patroni_maximum_lag_on_failover : 1048576
patroni_master_start_timeout : 300
# https://patroni.readthedocs.io/en/latest/replica_bootstrap.html#standby-cluster
patroni_standby_cluster :
host : "" # an address of remote master
port : "5432" # a port of remote master
# primary_slot_name: "" # which slot on the remote master to use for replication (optional)
# restore_command: "" # command to restore WAL records from the remote master to standby leader (optional)
# recovery_min_apply_delay: "" # how long to wait before actually apply WAL records on a standby leader (optional)
patroni_log_destination : stderr # or 'logfile'
# if patroni_log_destination: logfile
patroni_log_dir : /var/log/patroni
patroni_log_level : info
patroni_log_traceback_level : error
patroni_log_format : "%(asctime)s %(levelname)s: %(message)s"
patroni_log_dateformat : ""
patroni_log_max_queue_size : 1000
patroni_log_file_num : 4
patroni_log_file_size : 25000000 # bytes
patroni_log_loggers_patroni_postmaster : warning
patroni_log_loggers_urllib3 : warning # or 'debug'