# Patroni common options patroni_version: "3.0.4" patroni_install_official_repo: true patroni_play_group: "patroni" # Patroni cluster options patroni_cluster_name: "patroni-cluster" patroni_namespace: "/service/" # Patroni PostgreSQL common options patroni_postgresql_version: "15.4" patroni_postgresql_install_repo: true patroni_postgresql_system_locale: "en_US.UTF-8" patroni_postgresql_system_language: "{{ patroni_postgresql_system_locale }}" # 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_restapi_listen_address: "0.0.0.0" # Patroni SSL options patroni_ssl: true patroni_ssl_path: "/etc/patroni/ssl" patroni_self_signed_cert: false patroni_self_signed_cert_name: "cert" ## DCS options. Consul or Etcd patroni_dcs_exists: false patroni_dcs_type: "consul" ## WAL-G backup and restore options patroni_wal_g_install: false patroni_wal_g_restore_from_backup: false patroni_wal_g_pitr: 'latest' patroni_wal_g_restore_backup_name: 'LATEST' patroni_wal_g_pg_binary_name: 'wal-g-pg' patroni_wal_g_config_name: ".walg.json" patroni_wal_g_restore_config_name: ".walg-restore.json" patroni_restore_script: "{{ patroni_postgresql_home_dir }}/restore.sh" #patroni_postgresql_archive_command: "wal-g wal-push %p" #patroni_postgresql_restore_command: "wal-g wal-fetch %f %p" #patroni_cluster_bootstrap_command: "wal-g backup-fetch {{ patroni_wal_g_restore_backup_name }}" ## "restore_command" written to recovery.conf when configuring follower (create replica) #patroni_cluster_restore_command: "wal-g wal-fetch %f %p" #patroni_wal_g_create_replica_methods: # - {option: "command", value: "{{ patroni_cluster_bootstrap_command }}"} # - {option: "no_params", value: "True"} #patroni_basebackup_create_replica_methods: # - {option: "max-rate", value: "1000M"} # - {option: "checkpoint", value: "fast"} # More examples # patroni_postgresql_restore_command: "pgbackrest --stanza={{ pgbackrest_stanza }} archive-get %f %p" # restore WAL-s using pgbackrest # patroni_postgresql_restore_command: "pg_probackup-{{ pg_probackup_version }} archive-get -B {{ pg_probackup_dir }} --instance {{ pg_probackup_instance }} --wal-file-path=%p --wal-file-name=%f" # restore WAL-s using pg_probackup 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 patroni_cluster_bootstrap_method: "initdb --username {{ patroni_superuser_username }}" # or "wal-g", "pgbackrest", "pg_probackup" # 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: {} 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 .' }}" # postgresql parameters to bootstrap dcs (are parameters for example) patroni_postgresql_default_parameters: archive_mode: "on" archive_timeout: "1800s" max_connections: "1000" superuser_reserved_connections: "5" password_encryption: "{{ patroni_postgresql_password_encryption_algorithm }}" max_locks_per_transaction: "64" 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'