Skip to content

Commit a981b9c

Browse files
committed
reload configure with SIGHUP signal
Reloading the config by sending SIGHUP to the main process, instead of sending a POST request to the /-/reload endpoint, because the latter doesn't work when the basic auth is enabled. The password for the basic auth is encrypted using bcrypt, and I don't want to store the raw password The SIGHUP signal is sent to the process with PID 1 in the container, which is the main process.
1 parent c5cb118 commit a981b9c

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

ansible/roles/alertmanager/handlers/main.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,20 @@
1111
- service.enabled | bool
1212
- alertmanager_config.changed | bool
1313

14+
# NOTE(kiennt26): Reloading the config by sending SIGHUP to the main process, instead of sending a POST request
15+
# to the /-/reload endpoint, because the latter doesn't work when the basic auth is enabled.
16+
# The password for the basic auth is encrypted using bcrypt, and I don't want to store the raw password
17+
# The SIGHUP signal is sent to the process with PID 1 in the container, which is the main process.
1418
- name: Reload alertmanager config
1519
vars:
1620
service_name: "alertmanager"
1721
service: "{{ alertmanager_services[service_name] }}"
18-
ansible.builtin.uri:
19-
url: http://{{ api_interface_address }}:{{ alertmanager_port }}/-/reload
20-
method: POST
21-
use_proxy: false
22+
ansible.builtin.command: >
23+
/usr/bin/docker exec -i {{ alertmanager_container_name }} kill -SIGHUP 1
2224
register: result
2325
retries: 5
2426
delay: 20
25-
until: result.status == 200
27+
until: result.rc == 0
2628
when:
2729
- inventory_hostname in groups[service.group]
2830
- service.enabled | bool

ansible/roles/prometheus/handlers/main.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,20 @@
1313
or prometheus_alert_confs.changed | bool
1414
or prometheus_file_sd_confs.changed | bool
1515

16+
# NOTE(kiennt26): Reloading the config by sending SIGHUP to the main process, instead of sending a POST request
17+
# to the /-/reload endpoint, because the latter doesn't work when the basic auth is enabled.
18+
# The password for the basic auth is encrypted using bcrypt, and I don't want to store the raw password
19+
# The SIGHUP signal is sent to the process with PID 1 in the container, which is the main process.
1620
- name: Reload prometheus config
1721
vars:
1822
service_name: "prometheus"
1923
service: "{{ prometheus_services[service_name] }}"
20-
ansible.builtin.uri:
21-
url: http://{{ prometheus_vip_address if prometheus_vip_address is defined and prometheus_vip_address != "" and prometheus_active_passive_mode | bool else api_interface_address }}:{{ prometheus_port }}/-/reload
22-
method: PUT
23-
use_proxy: false
24+
ansible.builtin.command: >
25+
/usr/bin/docker exec -i {{ prometheus_container_name }} kill -SIGHUP 1
2426
register: result
2527
retries: 5
2628
delay: 20
27-
until: result.status == 200
29+
until: result.rc == 0
2830
when:
2931
- inventory_hostname in groups[service.group]
3032
- service.enabled | bool

0 commit comments

Comments
 (0)