mirror of
https://gitea.0xace.cc/ansible-galaxy/patroni.git
synced 2025-06-29 02:53:07 +00:00
add pending restart feature and bump postgresql default version to 15.4
This commit is contained in:
@ -77,3 +77,7 @@
|
||||
- name: Dynamic Patroni configuration
|
||||
include_tasks: dynamic_config.yaml
|
||||
tags: patroni_dynamic_configure
|
||||
|
||||
- name: Patroni restart if pending restart
|
||||
include_tasks: restart_pending.yaml
|
||||
tags: patroni_restart_pending
|
||||
|
46
tasks/restart_pending.yaml
Normal file
46
tasks/restart_pending.yaml
Normal file
@ -0,0 +1,46 @@
|
||||
---
|
||||
- name: Pending restart for Patroni
|
||||
block:
|
||||
- name: Wait for Patroni leader
|
||||
vars:
|
||||
_query: 'json.members[].role'
|
||||
ansible.builtin.uri:
|
||||
url: "{{ 'https://' if patroni_ssl else 'http://' }}{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}:{{ patroni_restapi_listen_port }}/cluster"
|
||||
method: GET
|
||||
body_format: json
|
||||
status_code:
|
||||
- 200
|
||||
- 503
|
||||
register: patroni_role
|
||||
until: patroni_role | json_query(_query) | regex_findall('leader') | count > 0
|
||||
retries: 100
|
||||
delay: 10
|
||||
|
||||
- name: Get Patroni nodes roles
|
||||
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: Restart if pending restart
|
||||
throttle: 1
|
||||
ansible.builtin.uri:
|
||||
url: "{{ 'https://' if patroni_ssl else 'http://' }}{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}:{{ patroni_restapi_listen_port }}/restart"
|
||||
user: "{{ patroni_restapi_username }}"
|
||||
password: "{{ patroni_restapi_password }}"
|
||||
method: POST
|
||||
body: '{ "restart_pending": true }'
|
||||
force_basic_auth: yes
|
||||
status_code:
|
||||
- 200
|
||||
- 503
|
||||
#when:
|
||||
# - "hostvars[inventory_hostname]['role'] == 'master'"
|
Reference in New Issue
Block a user