From 013b1f8b48dce0f602c8cbb24cba7de7d09b41f8 Mon Sep 17 00:00:00 2001 From: Greg Sutcliffe Date: Wed, 3 Jun 2026 14:51:36 +0100 Subject: [PATCH] Zabbix: Add COPR notification target Signed-off-by: Greg Sutcliffe --- .../zabbix_server/tasks/configure_api.yml | 48 +------ .../zabbix_server/tasks/configure_users.yml | 119 ++++++++++++++++++ 2 files changed, 121 insertions(+), 46 deletions(-) create mode 100644 roles/zabbix/zabbix_server/tasks/configure_users.yml diff --git a/roles/zabbix/zabbix_server/tasks/configure_api.yml b/roles/zabbix/zabbix_server/tasks/configure_api.yml index a0592bbc15..0437190b17 100644 --- a/roles/zabbix/zabbix_server/tasks/configure_api.yml +++ b/roles/zabbix/zabbix_server/tasks/configure_api.yml @@ -145,52 +145,8 @@ tags: - zabbix_triggers - - name: Create a new Zabbix user for Matrix triggers - community.zabbix.zabbix_user: - username: matrix-bot - name: Matrix - surname: Bot - role_name: Super admin role # needed to allow notifications without lots of config around usergroups - usrgrps: - - Zabbix administrators - passwd: "{{ (env == 'staging') | ternary(zabbix_stg_botuser_pwd, zabbix_botuser_pwd) }}" - user_medias: - - mediatype: Matrix - sendto: "{{ (env == 'staging') | ternary(zabbix_stg_matrix_roomid, zabbix_matrix_roomid) }}" - period: 1-7,00:00-24:00 - severity: - not_classified: yes - information: yes - warning: yes - average: yes - high: yes - disaster: yes - active: yes - state: present - tags: - - zabbix_users - - - name: Send alerts to Matrix - community.zabbix.zabbix_action: - name: "Send alerts to Matrix" - event_source: "trigger" - state: present - status: enabled - esc_period: 1m - conditions: - - type: "trigger_severity" - operator: ">=" - value: "Average" - operations: - - type: send_message - media_type: "Matrix" - send_to_users: - - "matrix-bot" - recovery_operations: - - type: send_message - media_type: "Matrix" - send_to_users: - - "matrix-bot" + - name: Configure Zabbix users and notifies + ansible.builtin.include_tasks: configure_users.yml tags: - zabbix_users - zabbix_triggers diff --git a/roles/zabbix/zabbix_server/tasks/configure_users.yml b/roles/zabbix/zabbix_server/tasks/configure_users.yml new file mode 100644 index 0000000000..d70cb643be --- /dev/null +++ b/roles/zabbix/zabbix_server/tasks/configure_users.yml @@ -0,0 +1,119 @@ +--- +# Configure the Zabbix users and notification channels + +# Use a block so we can specify the connection vars once +- name: API Block + vars: + ansible_zabbix_auth_key: "{{ zabbix_auth_key }}" + ansible_network_os: "{{ zabbix_network_os }}" + ansible_connection: "{{ zabbix_connection }}" + ansible_httpapi_port: "{{ zabbix_httpapi_port }}" + ansible_httpapi_use_ssl: "{{ zabbix_httpapi_use_ssl }}" + ansible_httpapi_validate_certs: "{{ zabbix_httpapi_validate_certs }}" + ansible_host: "{{ zabbix_server }}" + ansible_zabbix_url_path: "{{ zabbix_url_path }}" + tags: + - zabbix_configuration + block: + - name: Create an infra Zabbix user for Matrix triggers + community.zabbix.zabbix_user: + username: matrix-bot + name: Matrix + surname: Bot + role_name: Super admin role # needed to allow notifications without lots of config around usergroups + usrgrps: + - Zabbix administrators + passwd: "{{ (env == 'staging') | ternary(zabbix_stg_botuser_pwd, zabbix_botuser_pwd) }}" + user_medias: + - mediatype: Matrix + sendto: "{{ (env == 'staging') | ternary(zabbix_stg_matrix_roomid, zabbix_matrix_roomid) }}" + period: 1-7,00:00-24:00 + severity: + not_classified: yes + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + state: present + tags: + - zabbix_users + + - name: Send infra alerts to Matrix + community.zabbix.zabbix_action: + name: "Send alerts to Matrix" + event_source: "trigger" + state: present + status: enabled + esc_period: 1m + conditions: + - type: "trigger_severity" + operator: ">=" + value: "Average" + operations: + - type: send_message + media_type: "Matrix" + send_to_users: + - "matrix-bot" + recovery_operations: + - type: send_message + media_type: "Matrix" + send_to_users: + - "matrix-bot" + tags: + - zabbix_users + - zabbix_triggers + + - name: Create a Copr Zabbix user for Matrix triggers + community.zabbix.zabbix_user: + username: matrix-bot-copr + name: Matrix + surname: Bot + role_name: Super admin role # needed to allow notifications without lots of config around usergroups + usrgrps: + - Zabbix administrators + passwd: "{{ (env == 'staging') | ternary(zabbix_stg_botuser_pwd, zabbix_botuser_pwd) }}" + user_medias: + - mediatype: Matrix + sendto: "!rALCnapvdNTxUTuENl:matrix.org" # both prod and stg to #buildsys + period: 1-7,00:00-24:00 + severity: + not_classified: yes + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + state: present + tags: + - zabbix_users + + - name: Send COPR alerts to Matrix + community.zabbix.zabbix_action: + name: "Send COPR alerts to Matrix" + event_source: "trigger" + state: present + status: enabled + esc_period: 1m + conditions: + - type: "host_group" + operator: "equals" + value: "Copr_all_instances_aws" + - type: "host_group" + operator: "equals" + value: "Copr_hypervisor" + operations: + - type: send_message + media_type: "Matrix" + send_to_users: + - "matrix-bot-copr" + recovery_operations: + - type: send_message + media_type: "Matrix" + send_to_users: + - "matrix-bot-copr" + tags: + - zabbix_users + - zabbix_triggers