community.zabbix.zabbix_autoregister 模块 – 更新 Zabbix 自动注册

注意

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

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

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

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

community.zabbix 1.6.0 中的新增功能

概要

  • 此模块允许您修改 Zabbix 自动注册。

需求

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

  • python >= 3.9

参数

参数

注释

http_login_password

字符串

基本身份验证密码

http_login_user

字符串

基本身份验证登录名

tls_accept

列表 / 元素=字符串 / 必需

允许用于自动注册的传入连接类型。

unsecuretls_with_psk 或两者中选择。

tls_psk

字符串

TLS 连接使用此 PSK 值。

如果当前的 tls_accept 值为 unsecure,则此设置需要 tls_accept=tls_with_psk

tls_psk_identity

字符串

TLS 连接使用此 PSK 标识字符串。

PSK 标识字符串将通过网络以未加密的方式传输。因此,您不应在此处放置任何敏感信息。

如果当前的 tls_accept 值为 unsecure,则此设置需要 tls_accept=tls_with_psk

注释

注意

  • 当在 tls_psk_identitytls_psk 中设置任何值时,此模块将返回 changed=true,因为 Zabbix API 不会返回任何敏感信息供模块进行比较。

  • 请注意,此模块配置的是**全局 Zabbix 服务器设置**。如果您想创建一个自动注册操作,以便您的主机可以自动将其自己添加到监控中,请查看 community.zabbix.zabbix_action

示例

# 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 autoregistration
  # 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_autoregister:
    tls_accept:
      - unsecure
      - tls_with_psk
    tls_psk_identity: "PSK 001"
    tls_psk: "11111595725ac58dd977beef14b97461a7c1045b9a1c923453302c5473193478"

- name: Set unsecure to tls_accept
  # 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_autoregister:
    tls_accept: unsecure

返回值

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

描述

msg

字符串

操作的结果

返回:成功

示例:"Successfully updated global autoregistration setting"

作者

  • ONODERA Masaru(@masa-orca)