community.zabbix.zabbix_correlation 模块 – 创建/更新/删除 Zabbix 关联

注意

此模块是 community.zabbix 集合 (版本 3.2.0) 的一部分。

如果您正在使用 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.zabbix。您需要其他要求才能使用此模块,有关详细信息,请参阅 需求

要在 playbook 中使用它,请指定:community.zabbix.zabbix_correlation

community.zabbix 2.4.0 中的新增功能

概要

  • 此模块允许您创建、更新和删除 Zabbix 关联。

需求

在执行此模块的主机上需要以下需求。

  • python >= 3.9

参数

参数

注释

description

字符串

此关联的描述

filter

字典

过滤器。

conditions

列表 / 元素=字典 / 必需

条件。

formulaid

字符串

用于从自定义表达式引用条件的任意唯一 ID。

此参数的值必须仅包含大写字母。

如果过滤器的 *evaltype* 值为 custom_expression,则此参数是必需的。

hostgroup

字符串

主机组名称。

如果条件的 *type* 值为 new_event_host_group,则此参数是必需的。

newtag

字符串

新的事件标签。

如果条件的 *type* 值为 event_tag_pair,则此参数是必需的。

oldtag

字符串

旧的事件标签。

如果条件的 *type* 值为 event_tag_pair,则此参数是必需的。

operator

字符串

条件运算符。

如果条件的 *type* 值为 new_event_host_groupold_event_tag_valuenew_event_tag_value,则此参数是必需的。

如果条件的 *type* 值为 new_event_host_group,则只能选择 equalnot_equal

选项

  • "equal"

  • "not_equal"

  • "like"

  • "not_like"

tag

字符串

事件标签(旧的或新的)。

如果条件的 *type* 值为 old_event_tagnew_event_tagold_event_tag_valuenew_event_tag_value,则此参数是必需的。

type

字符串 / 必需

条件的类型。

选项

  • "old_event_tag"

  • "new_event_tag"

  • "new_event_host_group"

  • "event_tag_pair"

  • "old_event_tag_value"

  • "new_event_tag_value"

value

字符串

事件标签(旧的或新的)值。

如果条件的 *type* 值为 old_event_tag_valuenew_event_tag_value,则此参数是必需的。

evaltype

字符串 / 必需

过滤器的评估方法。

选项

  • "and_or"

  • "and"

  • "or"

  • "custom_expression"

formula

字符串

过滤器的自定义表达式。

如果 *evaltype* 的值为 custom_expression,则此参数是必需的。

http_login_password

字符串

基本身份验证密码

http_login_user

字符串

基本身份验证登录名

name

字符串 / 必需

此关联的名称

operations

列表 / 元素=字典

操作。

type

字符串 / 必需

操作的类型。

选项

  • "close_old_events"

  • "close_new_event"

state

字符串

关联的状态。

选项

  • "present" ← (默认)

  • "absent"

status

字符串

关联的状态。

选项

  • "enabled" ← (默认)

  • "disabled"

示例

# If you want to use Username and Password to be authenticated by Zabbix Server
- name: Set credentials to access Zabbix Server API
  ansible.builtin.set_fact:
    ansible_user: Admin
    ansible_httpapi_pass: zabbix

# If you want to use API token to be authenticated by Zabbix Server
# https://www.zabbix.com/documentation/current/en/manual/web_interface/frontend_sections/administration/general#api-tokens
- name: Set API token
  ansible.builtin.set_fact:
    ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895

- name: Create correlation of 'New event tag correlation'
  # set task level variables as we change ansible_connection plugin here
  vars:
    ansible_network_os: community.zabbix.zabbix
    ansible_connection: httpapi
    ansible_httpapi_port: 443
    ansible_httpapi_use_ssl: true
    ansible_httpapi_validate_certs: false
    ansible_zabbix_url_path: 'zabbixeu'  # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu
    ansible_host: zabbix-example-fqdn.org
  community.zabbix.zabbix_correlation:
    name: New event tag correlation
    filter:
      evaltype: and_or
      conditions:
        - type: new_event_tag
          tag: ok
    operations:
      - type: close_old_events

返回值

常见的返回值已在 此处 记录,以下是此模块独有的字段

描述

msg

字符串

操作的结果

返回:成功

示例:"Successfully created correlation"

作者

  • ONODERA Masaru(@masa-orca)