Skip to content

Commit

Permalink
Implemented option to disable handlers (#12)
Browse files Browse the repository at this point in the history
* Implemented option to disable handlers

* Added condition to execute HAProxy handler
  • Loading branch information
danopt authored Mar 6, 2023
1 parent 29e8c33 commit f962316
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ patroni_config_file: "{{ inventory_hostname }}.yml"
patroni_system_user: postgres
patroni_system_group: postgres

patroni_handlers_disable: false

# create a backup file before copying files on hosts
patroni_backup_on_copy: true

Expand Down
19 changes: 18 additions & 1 deletion tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,16 @@
owner: "{{ patroni_system_user }}"
group: "{{ patroni_system_group }}"
mode: 0600
register: patroni_config

- name: Check if Patroni handler has to be executed
debug:
msg: "Patroni config file was changed, handler will be triggered."
notify:
- restart patroni
when:
- patroni_config.changed | bool and
not patroni_handlers_disable | bool

- name: Create haproxy configuration file
template:
Expand All @@ -56,6 +64,15 @@
owner: root
group: root
mode: 0644
register: haproxy_config
when: patroni_install_haproxy

- name: Check if HAProxy handler has to be executed
debug:
msg: "HAProxy config file was changed, handler will be triggered."
notify:
- restart haproxy
when: patroni_install_haproxy
when:
- patroni_install_haproxy and
haproxy_config.changed | bool and
not patroni_handlers_disable | bool
1 change: 1 addition & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
tags: [patroni, patroni-configure]

- meta: flush_handlers
when: not patroni_handlers_disable | bool

- name: Ensure patroni is running
systemd:
Expand Down
8 changes: 8 additions & 0 deletions tasks/watchdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@
owner: root
group: root
mode: 0644
register: patroni_watchdog_config

- name: Check if watchdog handler has to be executed
debug:
msg: "Watchdog config file was changed, handler will be triggered."
notify:
- restart patroni-watchdog
when:
- patroni_watchdog_config.changed | bool and
not patroni_handlers_disable | bool

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

0 comments on commit f962316

Please sign in to comment.