From c8b3ef4aa09bf82f68a8f7e8a6240f72bf4cfe25 Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev Date: Mon, 31 Aug 2026 10:33:13 +0300 Subject: [PATCH] =?UTF-8?q?apprise:=20=D0=B7=D0=B0=D0=B2=D0=B5=D0=B4=D1=91?= =?UTF-8?q?=D0=BD=20=D0=B1=D0=B0=D0=BD=D0=B4=D0=BB=20alerts,=20netdata=20?= =?UTF-8?q?=D1=81=D0=BD=D0=BE=D0=B2=D0=B0=20=D0=B4=D0=BE=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D1=8F=D0=B5=D1=82=20=D1=83=D0=B2=D0=B5=D0=B4=D0=BE?= =?UTF-8?q?=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - netdata слал в бандл server, удалённый при переименовании в backups, и все health-алерты уходили в 404 - бандлы теперь рендерятся циклом: backups для отчётов backup-all.py, alerts для netdata --- files/apprise/alerts.template.cfg | 8 ++++++++ files/netdata/health_alarm_notify.template.conf | 12 ++++++------ playbook-apprise.yml | 12 +++++++++--- 3 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 files/apprise/alerts.template.cfg diff --git a/files/apprise/alerts.template.cfg b/files/apprise/alerts.template.cfg new file mode 100644 index 0000000..b64a22e --- /dev/null +++ b/files/apprise/alerts.template.cfg @@ -0,0 +1,8 @@ +# Бандл alerts — health-алерты netdata. Каналы совпадают с backups +# намеренно: разведены источники, чтобы позже можно было сменить адресатов +# алертов, не трогая отчёты бэкапов. +mailtos://{{ postbox_user }}:{{ postbox_pass }}@{{ postbox_host }}:{{ postbox_port }}/?from=notifications@vakhrushev.me&to={{ notifications_email }} +# Пароль бота экранируем дважды: jinja-фильтр urlencode оставляет '/' как есть +# (safe='/'), а в пароле он развалил бы путь URL. После urlencode литеральных +# процентов в строке нет, поэтому замена '/' на %2F безопасна. +matrix://apprise:{{ notifications_matrix_bot_password | urlencode | regex_replace('/', '%2F') }}@tuwunel:6167/{{ notifications_matrix_room }}?msgtype=text diff --git a/files/netdata/health_alarm_notify.template.conf b/files/netdata/health_alarm_notify.template.conf index 5523017..d41f7dc 100644 --- a/files/netdata/health_alarm_notify.template.conf +++ b/files/netdata/health_alarm_notify.template.conf @@ -3,13 +3,13 @@ SEND_EMAIL="NO" SEND_CUSTOM="YES" -DEFAULT_RECIPIENT_CUSTOM="server" +DEFAULT_RECIPIENT_CUSTOM="alerts" -role_recipients_custom[sysadmin]="server" -role_recipients_custom[domainadmin]="server" -role_recipients_custom[dba]="server" -role_recipients_custom[webmaster]="server" -role_recipients_custom[proxyadmin]="server" +role_recipients_custom[sysadmin]="alerts" +role_recipients_custom[domainadmin]="alerts" +role_recipients_custom[dba]="alerts" +role_recipients_custom[webmaster]="alerts" +role_recipients_custom[proxyadmin]="alerts" role_recipients_custom[silent]="" custom_sender() { diff --git a/playbook-apprise.yml b/playbook-apprise.yml index 97a294e..0366588 100644 --- a/playbook-apprise.yml +++ b/playbook-apprise.yml @@ -46,13 +46,19 @@ path: "{{ config_dir }}/server.cfg" state: "absent" - - name: "Copy apprise config" + # Бандл на источник уведомлений: backups — отчёты backup-all.py, alerts — + # health-алерты netdata. Каналы у них сейчас одинаковые, но адресатов можно + # развести, не трогая сами источники. + - name: "Copy apprise config bundles" ansible.builtin.template: - src: "./files/{{ app_name }}/backups.template.cfg" - dest: "{{ config_dir }}/backups.cfg" + src: "./files/{{ app_name }}/{{ item }}.template.cfg" + dest: "{{ config_dir }}/{{ item }}.cfg" owner: "{{ app_user }}" group: "{{ app_user }}" mode: "0640" + loop: + - "backups" + - "alerts" # Файл содержит секреты из vault — без no_log их печатает --diff. no_log: true notify: "Restart application"