mirror of
https://gitea.0xace.cc/ansible-galaxy/patroni.git
synced 2024-11-25 08:06:39 +00:00
235 lines
9.3 KiB
Django/Jinja
235 lines
9.3 KiB
Django/Jinja
#jinja2: trim_blocks:True,lstrip_blocks:True
|
|
---
|
|
scope: {{ patroni_cluster_name }}
|
|
name: {{ ansible_hostname }}
|
|
namespace: {{ patroni_namespace }}
|
|
|
|
{% if patroni_log_destination == 'logfile' %}
|
|
log:
|
|
level: {{ patroni_log_level |upper }}
|
|
traceback_level: {{ patroni_log_traceback_level |upper }}
|
|
format: {{ patroni_log_format |quote }}
|
|
dateformat: {{ patroni_log_dateformat |quote }}
|
|
max_queue_size: {{ patroni_log_max_queue_size |int }}
|
|
dir: {{ patroni_log_dir }}
|
|
file_num: {{ patroni_log_file_num |int }}
|
|
file_size: {{ patroni_log_file_size |int }}
|
|
loggers:
|
|
patroni.postmaster: {{ patroni_log_loggers_patroni_postmaster |upper }}
|
|
urllib3: {{ patroni_log_loggers_urllib3 |upper }}
|
|
{% endif %}
|
|
|
|
ctl:
|
|
certfile: {{ patroni_ssl_path }}/{{ patroni_self_signed_cert_name }}.crt
|
|
keyfile: {{ patroni_ssl_path }}/{{ patroni_self_signed_cert_name }}.key
|
|
cafile: {{ patroni_ssl_path }}/CA-cert.crt
|
|
|
|
restapi:
|
|
listen: 0.0.0.0:{{ patroni_restapi_listen_port }}
|
|
connect_address: {{ hostvars[inventory_hostname]['ansible_host'] }}:{{ patroni_restapi_listen_port }}
|
|
{% if patroni_ssl|bool %}
|
|
certfile: {{ patroni_ssl_path }}/{{ patroni_self_signed_cert_name }}.crt
|
|
keyfile: {{ patroni_ssl_path }}/{{ patroni_self_signed_cert_name }}.key
|
|
cafile: {{ patroni_ssl_path }}/CA-cert.crt
|
|
authentication:
|
|
username: {{ patroni_restapi_username }}
|
|
password: {{ patroni_restapi_password }}
|
|
{% endif %}
|
|
|
|
{% if not patroni_dcs_exists|bool and patroni_dcs_type == 'etcd' %}
|
|
etcd:
|
|
hosts: {% for host in groups['etcd'] %}{{ hostvars[host]['ansible_host'] }}:2379{% if not loop.last %},{% endif %}{% endfor %}
|
|
{% endif %}
|
|
{% if patroni_dcs_exists|bool and patroni_dcs_type == 'etcd' %}
|
|
etcd:
|
|
hosts: {% for etcd_hosts in patroni_etcd_hosts %}{{etcd_hosts.host}}:{{etcd_hosts.port}}{% if not loop.last %},{% endif %}{% endfor %}
|
|
{% endif %}
|
|
{% if patroni_dcs_exists|bool and patroni_dcs_type == 'consul' %}
|
|
consul:
|
|
hosts: {% for consul_hosts in patroni_consul_hosts %}{{consul_hosts.host}}:{{consul_hosts.port}}{% if not loop.last %},{% endif %}{% endfor %}
|
|
{% endif %}
|
|
{% if not patroni_dcs_exists|bool and patroni_dcs_type == 'consul' %}
|
|
consul:
|
|
host: localhost
|
|
{% endif %}
|
|
|
|
bootstrap:
|
|
method: {{ patroni_cluster_bootstrap_method }}
|
|
{% if patroni_cluster_bootstrap_method == 'wal-g' %}
|
|
wal-g:
|
|
command: {{ wal_g_patroni_cluster_bootstrap_command }}
|
|
no_params: True
|
|
recovery_conf:
|
|
recovery_target_action: promote
|
|
recovery_target_timeline: latest
|
|
restore_command: {{ wal_g_pg_binary_name }} wal-fetch %f %p
|
|
{% endif %}
|
|
{% if patroni_cluster_bootstrap_method == 'pg_probackup' %}
|
|
pg_probackup:
|
|
command: {{ pg_probackup_patroni_cluster_bootstrap_command }}
|
|
no_params: true
|
|
{% endif %}
|
|
dcs:
|
|
ttl: {{ patroni_ttl |d(30, true) |int }}
|
|
loop_wait: {{ patroni_loop_wait |d(10, true) |int }}
|
|
retry_timeout: {{ patroni_retry_timeout |d(10, true) |int }}
|
|
maximum_lag_on_failover: {{ patroni_maximum_lag_on_failover |d(1048576, true) |int }}
|
|
master_start_timeout: {{ patroni_master_start_timeout |d(300, true) |int }}
|
|
synchronous_mode: {{ patroni_synchronous_mode |string |d(false, true) |lower }}
|
|
synchronous_mode_strict: {{ patroni_synchronous_mode_strict |string |d(false, true) |lower }}
|
|
synchronous_node_count: {{ patroni_synchronous_node_count |d(1, true) |int }}
|
|
{% if patroni_standby_cluster.host is defined and patroni_standby_cluster.host | length > 0 %}
|
|
standby_cluster:
|
|
host: {{ patroni_standby_cluster.host }}
|
|
port: {{ patroni_standby_cluster.port }}
|
|
{% if patroni_standby_cluster.primary_slot_name is defined and patroni_standby_cluster.primary_slot_name | length > 0 %}
|
|
primary_slot_name: {{ patroni_standby_cluster.primary_slot_name }}
|
|
{% endif %}
|
|
{% if patroni_standby_cluster.restore_command is defined and patroni_standby_cluster.restore_command | length > 0 %}
|
|
restore_command: {{ patroni_standby_cluster.restore_command }}
|
|
{% endif %}
|
|
{% if patroni_standby_cluster.recovery_min_apply_delay is defined and patroni_standby_cluster.recovery_min_apply_delay | length > 0 %}
|
|
recovery_min_apply_delay: {{ patroni_standby_cluster.recovery_min_apply_delay }}
|
|
{% endif %}
|
|
{% endif %}
|
|
postgresql:
|
|
use_pg_rewind: {{ patroni_postgresql_use_pg_rewind |string |d(false, true) |lower }}
|
|
use_slots: true
|
|
parameters: {{ patroni_postgresql_parameters_combined }}
|
|
|
|
initdb: # List options to be passed on to initdb
|
|
- encoding: {{ patroni_postgresql_encoding }}
|
|
- locale: {{ patroni_postgresql_locale }}
|
|
- data-checksums
|
|
|
|
pg_hba: # Add following lines to pg_hba.conf after running 'initdb'
|
|
{% if patroni_ssl|bool %}
|
|
{% for host in groups.patroni %}
|
|
- hostssl all all {{ hostvars[host]['ansible_host'] }}/32 {{ patroni_postgresql_password_encryption_algorithm }}
|
|
{% endfor %}
|
|
{% else %}
|
|
{% for host in groups.patroni %}
|
|
- host all all {{ hostvars[host]['ansible_host'] }}/32 {{ patroni_postgresql_password_encryption_algorithm }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% for host in groups.patroni %}
|
|
- host replication {{ patroni_replication_username }} {{ hostvars[host]['ansible_host'] }}/32 {{ patroni_postgresql_password_encryption_algorithm }}
|
|
{% endfor %}
|
|
- hostssl all all 127.0.0.1/32 {{ patroni_postgresql_password_encryption_algorithm }}
|
|
- hostssl all all 0.0.0.0/0 scram-sha-256
|
|
- host replication replicator 0.0.0.0/0 scram-sha-256
|
|
|
|
|
|
postgresql:
|
|
listen: {{ hostvars[inventory_hostname]['ansible_host'] }},127.0.0.1:{{ patroni_postgresql_port }}
|
|
connect_address: {{ hostvars[inventory_hostname]['ansible_host'] }}:{{ patroni_postgresql_port }}
|
|
use_unix_socket: true
|
|
data_dir: {{ patroni_postgresql_home_dir }}/{{ patroni_postgresql_major_version }}/data
|
|
bin_dir: {{ patroni_postgresql_bin_dir }}
|
|
config_dir: {{ patroni_postgresql_home_dir }}/{{ patroni_postgresql_major_version }}/data
|
|
pgpass: {{ patroni_postgresql_home_dir }}/.pgpass_patroni
|
|
authentication:
|
|
replication:
|
|
username: {{ patroni_replication_username }}
|
|
password: {{ patroni_replication_password }}
|
|
{% if patroni_ssl|bool %}
|
|
sslcert: {{ patroni_ssl_path }}/{{ patroni_self_signed_cert_name }}.crt
|
|
sslkey: {{ patroni_ssl_path }}/{{ patroni_self_signed_cert_name}}.key
|
|
{% endif %}
|
|
superuser:
|
|
username: {{ patroni_superuser_username }}
|
|
password: {{ patroni_superuser_password }}
|
|
{% if patroni_ssl|bool %}
|
|
sslcert: {{ patroni_ssl_path }}/{{ patroni_self_signed_cert_name }}.crt
|
|
sslkey: {{ patroni_ssl_path }}/{{ patroni_self_signed_cert_name}}.key
|
|
{% endif %}
|
|
# rewind: # Has no effect on postgres 10 and lower
|
|
# username: rewind_user
|
|
# password: rewind_password
|
|
parameters:
|
|
unix_socket_directories: {{ patroni_postgresql_unix_socket_dir }}
|
|
{% if patroni_postgresql_stats_temp_directory_path is defined and patroni_postgresql_stats_temp_directory_path != 'none' %}
|
|
stats_temp_directory: {{ patroni_postgresql_stats_temp_directory_path }}
|
|
{% endif %}
|
|
{% if patroni_ssl|bool %}
|
|
ssl: on
|
|
ssl_cert_file: {{ patroni_ssl_path }}/{{ patroni_self_signed_cert_name }}.crt
|
|
ssl_key_file: {{ patroni_ssl_path }}/{{ patroni_self_signed_cert_name}}.key
|
|
{% endif %}
|
|
|
|
|
|
{% if patroni_postgresql_pg_ident is defined and patroni_postgresql_pg_ident | length > 0 %}
|
|
pg_ident:
|
|
{% for ident in patroni_postgresql_pg_ident %}
|
|
- {{ ident.mapname }} {{ ident.system_username }} {{ ident.pg_username }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
|
|
remove_data_directory_on_rewind_failure: {{ patroni_remove_data_directory_on_rewind_failure |string |d(false, true) |lower }}
|
|
remove_data_directory_on_diverged_timelines: {{ patroni_remove_data_directory_on_diverged_timelines |string |d(false, true) |lower }}
|
|
|
|
# callbacks:
|
|
# on_start:
|
|
# on_stop:
|
|
# on_restart:
|
|
# on_reload:
|
|
# on_role_change:
|
|
|
|
create_replica_methods:
|
|
{% if patroni_create_replica_methods is defined and patroni_create_replica_methods | length > 0 %}
|
|
{% for create_replica_method in patroni_create_replica_methods %}
|
|
- {{ create_replica_method }}
|
|
{% endfor %}
|
|
{% if 'pgbackrest' in patroni_create_replica_methods %}
|
|
pgbackrest:
|
|
{% for item in pgbackrest %}
|
|
{{ item.option }}: {{ item.value }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if 'wal_g' in patroni_create_replica_methods %}
|
|
wal_g:
|
|
{% for item in wal_g %}
|
|
{{ item.option }}: {{ item.value }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if 'basebackup' in patroni_create_replica_methods %}
|
|
basebackup:
|
|
{% for item in basebackup %}
|
|
{{ item.option }}: '{{ item.value }}'
|
|
{% endfor %}
|
|
{% if patroni_postgresql_major_version is version('10', '>=') and patroni_postgresql_wal_dir is defined and patroni_postgresql_wal_dir | length > 0 %}
|
|
waldir: {{ patroni_postgresql_wal_dir }}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% if 'pg_probackup' in patroni_create_replica_methods %}
|
|
pg_probackup:
|
|
{% for item in pg_probackup %}
|
|
{{ item.option }}: {{ item.value }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% else %}
|
|
- basebackup
|
|
basebackup:
|
|
max-rate: '100M'
|
|
{% endif %}
|
|
|
|
{% if patroni_postgresql_restore_command is defined and patroni_postgresql_restore_command | length > 0 %}
|
|
recovery_conf:
|
|
restore_command: {{ patroni_postgresql_restore_command }}
|
|
{% endif %}
|
|
|
|
watchdog:
|
|
mode: off # Allowed values: off, automatic, required
|
|
device: /dev/watchdog
|
|
safety_margin: 5
|
|
|
|
tags:
|
|
nofailover: false
|
|
noloadbalance: false
|
|
clonefrom: false
|
|
nosync: false
|
|
|
|
# specify a node to replicate from (cascading replication)
|
|
# replicatefrom: (node name)
|
|
|