fix: Don't reload services when restarting

Avoid triggering a reload of various role services when a restart is
needed. This avoids the race between restart and reload.

Signed-off-by: SuperQ <superq@gmail.com>
This commit is contained in:
SuperQ 2024-01-29 11:08:01 +01:00
parent 54232114d7
commit 954a01d17c
No known key found for this signature in database
GPG key ID: C646B23C9E3245F1
4 changed files with 16 additions and 8 deletions

View file

@ -6,6 +6,7 @@
daemon_reload: true
name: alertmanager
state: restarted
register: alertmanager_restarted
- name: Reload alertmanager
listen: "reload alertmanager"
@ -13,3 +14,4 @@
ansible.builtin.systemd:
name: alertmanager
state: reloaded
when: alertmanager_restarted is not defined

View file

@ -6,6 +6,7 @@
daemon_reload: true
name: blackbox_exporter
state: restarted
register: blackbox_exporter_restarted
- name: Reload blackbox_exporter
listen: "reload blackbox_exporter"
@ -13,3 +14,4 @@
ansible.builtin.systemd:
name: blackbox_exporter
state: reloaded
when: blackbox_exporter_restarted is not defined

View file

@ -6,6 +6,7 @@
daemon_reload: true
name: prometheus
state: restarted
register: prometheus_restarted
- name: Reload prometheus
listen: "reload prometheus"
@ -13,3 +14,4 @@
ansible.builtin.systemd:
name: prometheus
state: reloaded
when: prometheus_restarted is not defined

View file

@ -1,12 +1,4 @@
---
- name: Reload snmp_exporter
listen: "reload snmp_exporter"
become: true
ansible.builtin.systemd:
daemon_reload: true
name: snmp_exporter
state: reloaded
- name: Restart snmp_exporter
listen: "restart snmp_exporter"
become: true
@ -14,3 +6,13 @@
daemon_reload: true
name: snmp_exporter
state: restarted
register: snmp_exporter_restarted
- name: Reload snmp_exporter
listen: "reload snmp_exporter"
become: true
ansible.builtin.systemd:
daemon_reload: true
name: snmp_exporter
state: reloaded
when: snmp_exporter_restarted is not defined