2023-02-07 23:39:20 +00:00
|
|
|
---
|
|
|
|
- name: Merge user options for PostgreSQL part of Patroni config
|
|
|
|
set_fact:
|
|
|
|
patroni_postgresql_parameters_combined: "{{ patroni_postgresql_default_parameters | combine(patroni_postgresql_parameters|default({}), recursive=true) }}"
|
|
|
|
|
|
|
|
- name: Template Patroni default config
|
|
|
|
set_fact:
|
|
|
|
patroni_default_config: "{{ lookup('template', 'patroni.yaml.j2') | from_yaml }}"
|
|
|
|
|
|
|
|
- name: Print Patroni default config
|
|
|
|
debug:
|
|
|
|
msg: "{{ patroni_default_config }}"
|
|
|
|
verbosity: 2
|
|
|
|
|
|
|
|
- name: Merge user options with default Patroni config
|
|
|
|
set_fact:
|
|
|
|
patroni_config_combined: "{{ patroni_default_config | combine(patroni_config|default({}), recursive=true) }}"
|
|
|
|
|
|
|
|
- name: Create folder for Patroni config
|
|
|
|
file:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: directory
|
|
|
|
owner: "postgres"
|
|
|
|
group: "postgres"
|
|
|
|
loop:
|
|
|
|
- /etc/patroni
|
|
|
|
- /var/lib/pgsql_stats_tmp
|
|
|
|
|
2023-07-03 21:00:54 +00:00
|
|
|
- name: Check that the bootstrap {{ patroni_config_name }} exists
|
|
|
|
stat:
|
|
|
|
path: "/etc/patroni/{{ patroni_config_name }}"
|
|
|
|
register: patroni_config_file_exists_result
|
|
|
|
|
2024-05-26 14:55:39 +00:00
|
|
|
- name: Add WAL-G to patroni_create_replica_methods
|
|
|
|
set_fact:
|
|
|
|
patroni_create_replica_methods: "{{ patroni_create_replica_methods + [ 'wal_g' ] }}"
|
|
|
|
when:
|
|
|
|
- patroni_wal_g_install
|
|
|
|
|
2023-02-07 23:39:20 +00:00
|
|
|
- name: Propagate Patroni config
|
|
|
|
copy:
|
|
|
|
content: "{{ patroni_config_combined | to_nice_yaml }}"
|
2023-03-29 20:49:37 +00:00
|
|
|
dest: "/etc/patroni/{{ patroni_config_name }}"
|
2023-02-07 23:39:20 +00:00
|
|
|
owner: "postgres"
|
|
|
|
group: "postgres"
|
|
|
|
mode: 0644
|
2024-11-03 14:11:13 +00:00
|
|
|
backup: yes
|
2023-02-07 23:39:20 +00:00
|
|
|
register: patroni_config_file
|
2023-07-03 21:00:54 +00:00
|
|
|
when: not patroni_config_file_exists_result.stat.exists
|
2023-02-07 23:39:20 +00:00
|
|
|
notify: Restart Patroni
|
2023-07-21 14:13:51 +00:00
|
|
|
|
|
|
|
- name: Propagate Patroni restore script
|
|
|
|
template:
|
|
|
|
src: "restore.sh.j2"
|
|
|
|
dest: "{{ patroni_restore_script }}"
|
|
|
|
owner: "postgres"
|
|
|
|
group: "postgres"
|
|
|
|
mode: 0755
|
2024-11-03 14:11:13 +00:00
|
|
|
backup: yes
|