patroni/tasks/config.yaml

58 lines
1.7 KiB
YAML

---
- 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
- name: Check that the bootstrap {{ patroni_config_name }} exists
stat:
path: "/etc/patroni/{{ patroni_config_name }}"
register: patroni_config_file_exists_result
- 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
- name: Propagate Patroni config
copy:
content: "{{ patroni_config_combined | to_nice_yaml }}"
dest: "/etc/patroni/{{ patroni_config_name }}"
owner: "postgres"
group: "postgres"
mode: 0644
register: patroni_config_file
when: not patroni_config_file_exists_result.stat.exists
notify: Restart Patroni
- name: Propagate Patroni restore script
template:
src: "restore.sh.j2"
dest: "{{ patroni_restore_script }}"
owner: "postgres"
group: "postgres"
mode: 0755