community.zabbix.zabbix_discovery_rule module – Create/delete/update Zabbix discovery rules
Note
This module is part of the community.zabbix collection (version 1.9.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.zabbix
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.zabbix.zabbix_discovery_rule
.
Synopsis
Create discovery rule.
Delete existing discovery rule.
Update existing discovery rule with new options.
Requirements
The below requirements are needed on the host that executes this module.
python >= 2.6
Parameters
Parameter |
Comments |
---|---|
List of dictionaries of discovery check objects. For more information, review discovery check object documentation at https://www.zabbix.com/documentation/current/manual/api/reference/dcheck/object |
|
Source for host name. Possible values: DNS (default) IP discovery - discovery value of this check Options is available since Zabbix 4.4 Choices:
|
|
The value of this property differs depending on the type of the check:
|
|
Source for visible name. Possible values: none - (default) not specified DNS IP discovery - discovery value of this check Options is available since Zabbix 4.4 Choices:
|
|
One or several port ranges to check separated by commas. Used for all checks except for ICMP. |
|
SNMP community. Required for SNMPv1 and SNMPv2 agent checks. |
|
Authentication passphrase used for SNMPv3 agent checks with security level set to authNoPriv or authPriv. |
|
Authentication protocol used for SNMPv3 agent checks with security level set to authNoPriv or authPriv. Possible values: MD5 SHA Choices:
|
|
SNMPv3 context name. Used only by SNMPv3 checks. |
|
Privacy passphrase used for SNMPv3 agent checks with security level set to authPriv. |
|
Privacy protocol used for SNMPv3 agent checks with security level set to authPriv. Possible values: DES AES Choices:
|
|
Security level used for SNMPv3 agent checks. Possible values: noAuthNoPriv authNoPriv authPriv Choices:
|
|
Security name used for SNMPv3 agent checks. |
|
Type of check. Choices:
|
|
Whether to use this check as a device uniqueness criteria. Only a single unique check can be configured for a discovery rule. Used for Zabbix agent, SNMPv1, SNMPv2 and SNMPv3 agent checks. Possible values: no - (default) do not use this check as a uniqueness criteria yes - use this check as a uniqueness criteria Choices:
|
|
Execution interval of the discovery rule. Accepts seconds, time unit with suffix and user macro. Default: |
|
One or several IP ranges to check separated by commas. |
|
Zabbix user password. If not set the environment variable This option is deprecated with the move to httpapi connection and will be removed in the next release |
|
Zabbix user name. If not set the environment variable This option is deprecated with the move to httpapi connection and will be removed in the next release |
|
Name of the discovery rule. |
|
Name of the proxy used for discovery. |
|
URL of Zabbix server, with protocol (http or https). If not set the environment variable This option is deprecated with the move to httpapi connection and will be removed in the next release |
|
Create or delete discovery rules. Choices:
|
|
Whether the discovery rule is enabled. Possible values: enabled (default) disabled Choices:
|
|
The timeout of API request (seconds). This option is deprecated with the move to httpapi connection and will be removed in the next release Default: |
|
If set to False, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If not set the environment variable This option is deprecated with the move to httpapi connection and will be removed in the next release Choices:
|
Notes
Note
Only Zabbix >= 4.0 is supported.
If you use login_password=zabbix, the word “zabbix” is replaced by “********” in all module output, because login_password uses
no_log
. See this FAQ for more information.
Examples
# Set following variables for Zabbix Server host in play or inventory
- name: Set connection specific variables
set_fact:
ansible_network_os: community.zabbix.zabbix
ansible_connection: httpapi
ansible_httpapi_port: 80
ansible_httpapi_use_ssl: false
ansible_httpapi_validate_certs: false
ansible_zabbix_url_path: 'zabbixeu' # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu
# If you want to use Username and Password to be authenticated by Zabbix Server
- name: Set credentials to access Zabbix Server API
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
set_fact:
ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895
# Base create discovery rule example
- name: Create discovery rule with ICMP and zabbix agent checks
community.zabbix.zabbix_discovery_rule:
name: ACME
state: present
iprange: 192.168.1.1-255
dchecks:
- type: ICMP
- type: Zabbix
key: "system.hostname"
ports: 10050
uniq: yes
host_source: "discovery"
# Base update (add new dcheck) discovery rule example
- name: Create discovery rule with ICMP and zabbix agent checks
community.zabbix.zabbix_discovery_rule:
name: ACME
state: present
iprange: 192.168.1.1-255
dchecks:
- type: SNMPv3
snmp_community: CUSTOMER@snmp3-readonly
ports: "161"
key: iso.3.6.1.2.1.1.1.0
snmpv3_contextname: "ContextName"
snmpv3_securityname: "SecurityName"
snmpv3_securitylevel: "authPriv"
snmpv3_authprotocol: "SHA"
snmpv3_authpassphrase: "SeCrEt"
snmpv3_privprotocol: "AES"
snmpv3_privpassphrase: "TopSecret"
uniq: no
host_source: "DNS"
name_source: "None"
# Base delete discovery rule example
- name: Delete discovery rule
community.zabbix.zabbix_discovery_rule:
name: ACME
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Discovery rule name. Returned: on success Sample: |
|
Discovery rule id. Returned: on success Sample: |
|
The result of the operation Returned: always Sample: |
|
Discovery rule state at the end of execution. Returned: on success Sample: |