fix(monitoring): Prometheus читает новый конфиг, а не старый inode
ansible-core-mon / deploy (push) Successful in 13s

Файл в bind-mount не обновлялся после записи Ansible, поэтому ger-nod-02 не попадал в цели.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
karpenokandCursor committed 2026-11-12 13:00:15 +07:00
1 parent 408dfd09c3
commit a54a25ebb7
3 files changed
+11 -33

No files matched your search

@@ -1,26 +0,0 @@
---
- name: Reload Prometheus configuration
ansible.builtin.uri:
url: http://127.0.0.1:9090/-/reload
method: POST
status_code: 200
register: prometheus_reload
until: prometheus_reload.status == 200
retries: 10
delay: 3
when: prometheus_config_reload | default(true) | bool
ignore_errors: true
- name: Restart Prometheus after failed reload
ansible.builtin.command: docker compose -f {{ monitoring_dir }}/compose.yaml restart prometheus
args:
chdir: "{{ monitoring_dir }}"
when:
- prometheus_config_reload | default(true) | bool
- prometheus_reload is defined
- prometheus_reload is failed or (prometheus_reload.status | default(0) != 200)
- name: Restart Grafana
ansible.builtin.command: docker compose -f {{ monitoring_dir }}/compose.yaml restart grafana
args:
chdir: "{{ monitoring_dir }}"
@@ -55,7 +55,7 @@
owner: root
group: root
mode: "0644"
notify: Reload Prometheus configuration
register: prometheus_config
- name: Установить правила алертов Prometheus
ansible.builtin.copy:
@@ -64,7 +64,7 @@
owner: root
group: root
mode: "0644"
notify: Reload Prometheus configuration
register: prometheus_alerts
- name: Установить конфигурацию Alertmanager
ansible.builtin.template:
@@ -105,7 +105,6 @@
owner: root
group: root
mode: "0644"
notify: Restart Grafana
- name: Установить compose.yaml для стека мониторинга
ansible.builtin.template:
@@ -114,12 +113,18 @@
owner: root
group: root
mode: "0644"
register: monitoring_compose
- name: Запустить стек мониторинга через Docker Compose
ansible.builtin.command: docker compose -f {{ monitoring_dir }}/compose.yaml up -d --remove-orphans
register: compose_up
changed_when: "'Started' in compose_up.stderr or 'Created' in compose_up.stderr or 'Recreated' in compose_up.stderr or 'Pulled' in compose_up.stderr"
- name: Пересоздать Prometheus, чтобы подхватить конфиг
ansible.builtin.command: docker compose -f {{ monitoring_dir }}/compose.yaml up -d --force-recreate --no-deps prometheus
when: prometheus_config is changed or prometheus_alerts is changed or monitoring_compose is changed
changed_when: true
- name: Дождаться готовности Ntfy
ansible.builtin.uri:
url: "http://127.0.0.1:80/v1/health"
@@ -11,8 +11,7 @@ services:
- "--storage.tsdb.retention.time={{ prometheus_retention }}"
- "--web.enable-lifecycle"
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ./prometheus/alerts.yml:/etc/prometheus/alerts.yml:ro
- ./prometheus:/etc/prometheus:ro
- ./prometheus_data:/prometheus
ports:
- "9090:9090"
@@ -27,7 +26,7 @@ services:
- "--config.file=/etc/alertmanager/alertmanager.yml"
- "--storage.path=/alertmanager"
volumes:
- ./alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml:ro
- ./alertmanager:/etc/alertmanager:ro
- ./alertmanager_data:/alertmanager
ports:
- "9093:9093"
@@ -58,7 +57,7 @@ services:
command:
- "--configs=/etc/alertmanager-ntfy/config.yml"
volumes:
- ./alertmanager-ntfy/config.yml:/etc/alertmanager-ntfy/config.yml:ro
- ./alertmanager-ntfy:/etc/alertmanager-ntfy:ro
depends_on:
- ntfy