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) }}"
|
|
|
|
|
2023-07-03 21:00:54 +00:00
|
|
|
- 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) }}"
|
|
|
|
|
2023-02-07 23:39:20 +00:00
|
|
|
- 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
|
|
|
|
|
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
|
|
|
|
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
|