community.zabbix.zabbix_proxy 模块 – 创建/删除/获取/更新 Zabbix 代理

注意

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

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

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

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

概要

  • 此模块允许您创建、修改、获取和删除 Zabbix 代理条目。

要求

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

  • python >= 3.9

参数

参数

注释

address

字符串

Zabbix 7.0 中引入的参数。

要连接到的 IP 地址或 DNS 名称。

如果 Zabbix 代理操作模式为被动模式,则为必填项

allowed_addresses

字符串

Zabbix 7.0 中引入的参数。

活动 Zabbix 代理的逗号分隔的 IP 地址或 DNS 名称。

ca_cert

别名:tls_issuer

字符串

证书颁发者。

custom_timeouts

整数

Zabbix 7.0 中引入的参数。

是否在代理级别覆盖全局项目超时。

0 - 使用全局设置;1 - 覆盖超时。

选项

  • 0 ← (默认)

  • 1

description

字符串

代理的描述。

http_login_password

字符串

基本身份验证密码

http_login_user

字符串

基本身份验证登录名

interface

字典

对于 Zabbix 版本 >= 7.0 已弃用。

当代理处于被动模式时,包含接口参数的字典。

更多信息,请查看代理接口文档:

https://www.zabbix.com/documentation/current/en/manual/api/reference/proxy/object#proxy-interface.

默认值: {}

dns

字符串

代理接口的 DNS 名称。

如果 *useip=0*,则为必填项。

默认值: ""

ip

字符串

代理接口使用的 IP 地址。

如果 *useip=1*,则为必填项。

默认值: ""

port

字符串

代理接口使用的端口。

默认值: "10051"

useip

整数

使用 IP 地址而不是 DNS 名称连接到代理接口。

0 (不使用 ip),1 (使用 ip)。

选项

  • 0 ← (默认)

  • 1

local_address

字符串

Zabbix 7.0 中引入的参数。

活动代理的地址。要连接到的 IP 地址或 DNS 名称。

如果 proxy_groupid 不为 0,则为必填项

local_port

字符串

Zabbix 7.0 中引入的参数。

要连接到的本地代理端口号。

如果 proxy_groupid 不为 0,则支持

默认值: "10051"

operating_mode

字符串

Zabbix 7.0 中引入的参数。

代理类型。

选项

  • "active" ← (默认)

  • "passive"

port

字符串

Zabbix 7.0 中引入的参数。

要连接到的端口号。

如果 Zabbix 代理操作模式为被动模式,则支持。

默认值: "10051"

proxy_address

字符串

对于 Zabbix 版本 >= 7.0 已弃用。

允许来自活动代理请求的 IP/CIDR 地址或 DNS 名称的逗号分隔列表。

需要 *status=active*。

proxy_group

字符串

Zabbix 7.0 中引入的参数。

代理组名称。

proxy_name

字符串 / 必填

Zabbix 中代理的名称。

state

字符串

代理的状态。

present 上,如果代理不存在,它将创建;如果关联数据不同,则更新代理。

absent 上,如果代理存在,将删除。

选项

  • "present" ← (默认)

  • "absent"

status

字符串

对于 Zabbix 版本 >= 7.0 已弃用。

代理类型。(4 - 活动,5 - 被动)

选项

  • "active" ← (默认)

  • "passive"

timeout_browser

字符串

Zabbix 7.0 中引入的参数。

在浏览器类型检查处理上花费不超过这么多秒。

接受秒或带后缀的单位(例如,30s、1m)。

可能值范围:1-600s。

如果 custom_timeouts 设置为 1,则为必填项。

timeout_db_monitor

字符串

Zabbix 7.0 中引入的参数。

在数据库检查处理上花费不超过这么多秒。

接受秒或带后缀的单位(例如,30s、1m)。

可能值范围:1-600s。

如果 custom_timeouts 设置为 1,则为必填项。

timeout_external_check

字符串

Zabbix 7.0 中引入的参数。

在外部检查处理上花费不超过这么多秒。

接受秒或带后缀的单位(例如,30s、1m)。

可能值范围:1-600s。

如果 custom_timeouts 设置为 1,则为必填项。

timeout_http_agent

字符串

Zabbix 7.0 中引入的参数。

在 HTTPagent 检查处理上花费不超过这么多秒。

接受秒或带后缀的单位(例如,30s、1m)。

可能值范围:1-600s。

如果 custom_timeouts 设置为 1,则为必填项。

timeout_script

字符串

Zabbix 7.0 中引入的参数。

在脚本类型检查处理上花费不超过这么多秒。

接受秒或带后缀的单位(例如,30s、1m)。

可能值范围:1-600s。

如果 custom_timeouts 设置为 1,则为必填项。

timeout_simple_check

字符串

Zabbix 7.0 中引入的参数。

在简单检查处理上花费不超过这么多秒。

接受秒或带后缀的单位(例如,30s、1m)。

可能值范围:1-600s。

如果 custom_timeouts 设置为 1,则为必填项。

timeout_snmp_agent

字符串

Zabbix 7.0 中引入的参数。

在 SNMP 代理检查处理上花费不超过这么多秒。

接受秒或带后缀的单位(例如,30s、1m)。

可能值范围:1-600s。

如果 custom_timeouts 设置为 1,则为必填项。

timeout_ssh_agent

字符串

Zabbix 7.0 中引入的参数。

在 SSH 检查处理上花费不超过这么多秒。

接受秒或带后缀的单位(例如,30s、1m)。

可能值范围:1-600s。

如果 custom_timeouts 设置为 1,则为必填项。

timeout_telnet_agent

字符串

Zabbix 7.0 中引入的参数。

在 Telnet 检查处理上花费不超过这么多秒。

接受秒或带后缀的单位(例如,30s、1m)。

可能值范围:1-600s。

如果 custom_timeouts 设置为 1,则为必填项。

timeout_zabbix_agent

字符串

Zabbix 7.0 中引入的参数。

在 Zabbix 代理检查处理上花费不超过这么多秒。

接受秒或带后缀的单位(例如,30s、1m)。

可能值范围:1-600s。

如果 custom_timeouts 设置为 1,则为必填项。

tls_accept

字符串

来自代理的连接。

选项

  • "no_encryption" ← (默认)

  • "PSK"

  • "certificate"

tls_connect

字符串

到代理的连接。

选项

  • "no_encryption" ← (默认)

  • "PSK"

  • "certificate"

tls_psk

字符串

预共享密钥,至少 32 个十六进制数字。如果 *tls_connect* 或 *tls_accept* 启用了 PSK,则为必填项。

tls_psk_identity

字符串

PSK 身份。如果 *tls_connect* 或 *tls_accept* 启用了 PSK,则为必填项。

tls_subject

字符串

证书主题。

示例

# 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 or update a proxy with proxy type active (Zabbix version < 7.0)
  # 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_proxy:
    proxy_name: ExampleProxy
    description: ExampleProxy
    status: active
    state: present
    proxy_address: ExampleProxy.local

- name: Create a new passive proxy using only its IP (Zabbix version < 7.0)
  # 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_proxy:
    proxy_name: ExampleProxy
    description: ExampleProxy
    status: passive
    state: present
    interface:
      useip: 1
      ip: 10.1.1.2
      port: 10051

- name: Create a new passive proxy using only its DNS (Zabbix version < 7.0)
  # 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_proxy:
    proxy_name: ExampleProxy
    description: ExampleProxy
    status: passive
    state: present
    interface:
      dns: proxy.example.com
      port: 10051

- name: Create or update a proxy with proxy type active (Zabbix version >= 7.0)
  # 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_proxy:
    proxy_name: ExampleProxy
    description: ExampleProxy
    operating_mode: operating_mode
    state: present
    allowed_addresses: ExampleProxy.local

- name: Create a new passive proxy using only its IP (Zabbix version >= 7.0)
  # 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_proxy:
    proxy_name: ExampleProxy
    description: ExampleProxy
    operating_mode: passive
    state: present
    address: 10.1.1.2
    port: 10051

- name: Create a new passive proxy using only its DNS (Zabbix version >= 7.0)
  # 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_proxy:
    proxy_name: ExampleProxy
    description: ExampleProxy
    operating_mode: passive
    state: present
    address: proxy.example.com
    port: 10051

作者

  • Alen Komic (@akomic)