community.zabbix.zabbix_regexp 模块 – 创建/更新/删除 Zabbix 正则表达式

注意

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

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

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

要在剧本中使用它,请指定:community.zabbix.zabbix_regexp

community.zabbix 2.1.0 中的新增功能

概要

  • 此模块允许您创建、更新和删除 Zabbix 正则表达式。

要求

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

  • python >= 3.9

参数

参数

注释

expressions

列表 / 元素=字典

表达式的列表。

当所有表达式都返回 true 时,正则表达式返回 true。

state=present 时必需。

case_sensitive

布尔值

如果为 true,则表达式区分大小写。

选项

  • false ← (默认)

  • true

exp_delimiter

字符串

表达式的分隔符。

如果 expression_type 为 any_character_string_included,则使用。

默认值为 ,

选项

  • ","

  • "."

  • "/"

expression

字符串 / 必需

表达式字符串

expression_type

字符串 / 必需

表达式字符串

选项

  • "character_string_included"

  • "any_character_string_included"

  • "character_string_not_included"

  • "result_is_true"

  • "result_is_false"

http_login_password

字符串

基本身份验证密码

http_login_user

字符串

基本身份验证用户名

name

字符串 / 必需

此正则表达式的名称

state

字符串

正则表达式的状态。

选项

  • "present" ← (默认)

  • "absent"

test_string

字符串

此正则表达式的测试字符串

备注

注意

  • 仅支持 Zabbix >= 6.0。

示例

# 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: Update regexp of 'File systems for discovery'
  # 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_regexp:
    name: File systems for discovery
    test_string: ext2
    expressions:
      - expression: "^(btrfs|ext2|ext3|ext4|reiser|xfs|ffs|ufs|jfs|jfs2|vxfs|hfs|apfs|refs|ntfs|fat32|zfs)$"
        expression_type: result_is_true

返回值

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

描述

msg

字符串

操作的结果

返回:成功

示例:"Successfully updated regular expression setting"

作者

  • ONODERA Masaru(@masa-orca)