mirror of
https://gitea.0xace.cc/ansible-galaxy/patroni.git
synced 2024-11-24 23:56:39 +00:00
cleanup
This commit is contained in:
parent
2ac7f6244f
commit
e862d9f27b
@ -36,9 +36,21 @@ patroni_play_group: "patroni"
|
||||
patroni_dcs_exists: false
|
||||
patroni_dcs_type: "consul"
|
||||
|
||||
## Backup options
|
||||
## Backup and restore options
|
||||
patroni_wal_g_install: false
|
||||
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 '' }}"
|
||||
|
||||
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 '' }}"
|
||||
|
||||
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
|
||||
@ -77,6 +89,14 @@ patroni_create_replica_methods:
|
||||
# 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 .' }}"
|
||||
archive_mode: "on"
|
||||
archive_timeout: "1800s"
|
||||
|
||||
# postgresql parameters to bootstrap dcs (are parameters for example)
|
||||
patroni_postgresql_default_parameters:
|
||||
max_connections: "1000"
|
||||
@ -111,9 +131,6 @@ patroni_postgresql_default_parameters:
|
||||
autovacuum_vacuum_cost_delay: "2"
|
||||
autovacuum_naptime: "1s"
|
||||
max_files_per_process: "4096"
|
||||
archive_mode: "on"
|
||||
archive_timeout: "1800s"
|
||||
archive_command: "cd ."
|
||||
wal_level: "replica"
|
||||
wal_keep_size: "2GB"
|
||||
max_wal_senders: "10"
|
||||
|
@ -3,6 +3,10 @@
|
||||
set_fact:
|
||||
patroni_postgresql_parameters_combined: "{{ patroni_postgresql_default_parameters | combine(patroni_postgresql_parameters|default({}), recursive=true) }}"
|
||||
|
||||
- name: Merge backup options for PostgreSQL part of Patroni config
|
||||
set_fact:
|
||||
patroni_postgresql_parameters_combined: "{{ patroni_postgresql_parameters_combined | combine(patroni_postgresql_backup_parameters['postgresql']['parameters']|default({}), recursive=true) }}"
|
||||
|
||||
- name: Template Patroni default config
|
||||
set_fact:
|
||||
patroni_default_config: "{{ lookup('template', 'patroni.yaml.j2') | from_yaml }}"
|
||||
@ -26,6 +30,11 @@
|
||||
- /etc/patroni
|
||||
- /var/lib/pgsql_stats_tmp
|
||||
|
||||
- name: Check that the bootstrap {{ patroni_config_name }} exists
|
||||
stat:
|
||||
path: "/etc/patroni/{{ patroni_config_name }}"
|
||||
register: patroni_config_file_exists_result
|
||||
|
||||
- name: Propagate Patroni config
|
||||
copy:
|
||||
content: "{{ patroni_config_combined | to_nice_yaml }}"
|
||||
@ -34,4 +43,5 @@
|
||||
group: "postgres"
|
||||
mode: 0644
|
||||
register: patroni_config_file
|
||||
when: not patroni_config_file_exists_result.stat.exists
|
||||
notify: Restart Patroni
|
||||
|
@ -1,4 +1,8 @@
|
||||
---
|
||||
- name: Merge Patroni dynamic parameters for backup
|
||||
set_fact:
|
||||
patroni_postgresql_dynamic_parameters: "{{ patroni_postgresql_dynamic_parameters | combine(patroni_postgresql_backup_parameters, recursive=true) }}"
|
||||
|
||||
- name: Propagate Patroni dynamic config
|
||||
copy:
|
||||
content: "{{ patroni_postgresql_dynamic_parameters | to_nice_json }}"
|
||||
|
@ -72,7 +72,7 @@
|
||||
|
||||
- name: "Dynamic Patroni configuration"
|
||||
include_tasks: dynamic_config.yaml
|
||||
when:
|
||||
- patroni_postgresql_dynamic_parameters
|
||||
#when:
|
||||
# - patroni_postgresql_dynamic_parameters
|
||||
tags: patroni_dynamic_configure
|
||||
|
||||
|
@ -57,12 +57,12 @@ bootstrap:
|
||||
method: {{ patroni_cluster_bootstrap_method }}
|
||||
{% if patroni_cluster_bootstrap_method == 'wal-g' %}
|
||||
wal-g:
|
||||
command: {{ wal_g_patroni_cluster_bootstrap_command }}
|
||||
command: {{ patroni_wal_g_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
|
||||
restore_command: {{ patroni_wal_g_pg_binary_name }} wal-fetch %f %p
|
||||
{% endif %}
|
||||
{% if patroni_cluster_bootstrap_method == 'pg_probackup' %}
|
||||
pg_probackup:
|
||||
@ -190,13 +190,13 @@ postgresql:
|
||||
{% endif %}
|
||||
{% if 'wal_g' in patroni_create_replica_methods %}
|
||||
wal_g:
|
||||
{% for item in wal_g %}
|
||||
{% for item in patroni_wal_g_create_replica_methods %}
|
||||
{{ item.option }}: {{ item.value }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'basebackup' in patroni_create_replica_methods %}
|
||||
basebackup:
|
||||
{% for item in basebackup %}
|
||||
{% for item in patroni_basebackup_create_replica_methods %}
|
||||
{{ 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 %}
|
||||
@ -205,7 +205,7 @@ postgresql:
|
||||
{% endif %}
|
||||
{% if 'pg_probackup' in patroni_create_replica_methods %}
|
||||
pg_probackup:
|
||||
{% for item in pg_probackup %}
|
||||
{% for item in patroni_pg_probackup_create_replica_methods %}
|
||||
{{ item.option }}: {{ item.value }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
@ -215,7 +215,7 @@ postgresql:
|
||||
max-rate: '100M'
|
||||
{% endif %}
|
||||
|
||||
{% if patroni_postgresql_restore_command is defined and patroni_postgresql_restore_command | length > 0 %}
|
||||
{% if patroni_postgresql_restore_command is defined and patroni_postgresql_restore_command | length > 0 and patroni_wal_g_install %}
|
||||
recovery_conf:
|
||||
restore_command: {{ patroni_postgresql_restore_command }}
|
||||
{% endif %}
|
||||
|
Loading…
Reference in New Issue
Block a user