2023-02-07 23:39:20 +00:00
|
|
|
---
|
2023-07-03 21:00:54 +00:00
|
|
|
- name: Merge Patroni dynamic parameters for backup
|
|
|
|
set_fact:
|
|
|
|
patroni_postgresql_dynamic_parameters: "{{ patroni_postgresql_dynamic_parameters | combine(patroni_postgresql_backup_parameters, recursive=true) }}"
|
|
|
|
|
2023-02-07 23:39:20 +00:00
|
|
|
- name: Propagate Patroni dynamic config
|
|
|
|
copy:
|
|
|
|
content: "{{ patroni_postgresql_dynamic_parameters | to_nice_json }}"
|
|
|
|
dest: "/etc/patroni/dynamic.json"
|
|
|
|
owner: "postgres"
|
|
|
|
group: "postgres"
|
|
|
|
mode: 0644
|
|
|
|
register: patroni_dynamic_config_file
|
|
|
|
|
|
|
|
- name: Dynamic configuration parameters for Patroni
|
|
|
|
when: patroni_dynamic_config_file.changed
|
|
|
|
block:
|
|
|
|
- name: Find Patroni master
|
|
|
|
ansible.builtin.uri:
|
|
|
|
url: "{{ 'https://' if patroni_ssl else 'http://' }}{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}:{{ patroni_restapi_listen_port }}"
|
|
|
|
method: GET
|
|
|
|
body_format: json
|
|
|
|
status_code:
|
|
|
|
- 200
|
|
|
|
- 503
|
|
|
|
register: patroni_role
|
|
|
|
|
|
|
|
- name: Set fact about roles
|
|
|
|
set_fact:
|
|
|
|
role: "{{ patroni_role.json.role }}"
|
|
|
|
|
|
|
|
- name: Apply dynamic configuration parameters for Patroni
|
|
|
|
ansible.builtin.uri:
|
|
|
|
url: "{{ 'https://' if patroni_ssl else 'http://' }}{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}:{{ patroni_restapi_listen_port }}/config"
|
|
|
|
user: "{{ patroni_restapi_username }}"
|
|
|
|
password: "{{ patroni_restapi_password }}"
|
|
|
|
method: PATCH
|
|
|
|
body: "{{ patroni_postgresql_dynamic_parameters | to_nice_json }}"
|
|
|
|
force_basic_auth: yes
|
|
|
|
when:
|
|
|
|
- "hostvars[inventory_hostname]['role'] == 'master'"
|
|
|
|
|