Skip to content

Commit f962316

Browse files
authored
Implemented option to disable handlers (#12)
* Implemented option to disable handlers * Added condition to execute HAProxy handler
1 parent 29e8c33 commit f962316

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ patroni_config_file: "{{ inventory_hostname }}.yml"
1212
patroni_system_user: postgres
1313
patroni_system_group: postgres
1414

15+
patroni_handlers_disable: false
16+
1517
# create a backup file before copying files on hosts
1618
patroni_backup_on_copy: true
1719

tasks/configure.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,16 @@
4646
owner: "{{ patroni_system_user }}"
4747
group: "{{ patroni_system_group }}"
4848
mode: 0600
49+
register: patroni_config
50+
51+
- name: Check if Patroni handler has to be executed
52+
debug:
53+
msg: "Patroni config file was changed, handler will be triggered."
4954
notify:
5055
- restart patroni
56+
when:
57+
- patroni_config.changed | bool and
58+
not patroni_handlers_disable | bool
5159

5260
- name: Create haproxy configuration file
5361
template:
@@ -56,6 +64,15 @@
5664
owner: root
5765
group: root
5866
mode: 0644
67+
register: haproxy_config
68+
when: patroni_install_haproxy
69+
70+
- name: Check if HAProxy handler has to be executed
71+
debug:
72+
msg: "HAProxy config file was changed, handler will be triggered."
5973
notify:
6074
- restart haproxy
61-
when: patroni_install_haproxy
75+
when:
76+
- patroni_install_haproxy and
77+
haproxy_config.changed | bool and
78+
not patroni_handlers_disable | bool

tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
tags: [patroni, patroni-configure]
99

1010
- meta: flush_handlers
11+
when: not patroni_handlers_disable | bool
1112

1213
- name: Ensure patroni is running
1314
systemd:

tasks/watchdog.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,16 @@
2020
owner: root
2121
group: root
2222
mode: 0644
23+
register: patroni_watchdog_config
24+
25+
- name: Check if watchdog handler has to be executed
26+
debug:
27+
msg: "Watchdog config file was changed, handler will be triggered."
2328
notify:
2429
- restart patroni-watchdog
30+
when:
31+
- patroni_watchdog_config.changed | bool and
32+
not patroni_handlers_disable | bool
2533

2634
# Dirty hack. See https://bugs.launchpad.net/ubuntu/+source/watchdog/+bug/1448924
2735
- name: Enable watchdog daemon to start on boot

0 commit comments

Comments
 (0)