community.zabbix.zabbix_discovery_rule – Create/delete/update Zabbix discovery rules
Note
This plugin is part of the community.zabbix collection (version 1.5.1).
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
.
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.
zabbix-api >= 0.5.4
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: “1h” |
|
Basic Auth password |
|
Basic Auth login |
|
One or several IP ranges to check separated by commas. |
|
Zabbix user password. If not set the environment variable |
|
Zabbix user name. If not set the environment variable |
|
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 |
|
Create or delete discovery rules. Choices:
|
|
Whether the discovery rule is enabled. Possible values: enabled (default) disabled Choices:
|
|
The timeout of API request (seconds). Default: 10 |
|
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 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
# Base create discovery rule example
- name: Create discovery rule with ICMP and zabbix agent checks
community.zabbix.zabbix_discovery_rule:
server_url: "http://zabbix.example.com/zabbix/"
login_user: admin
login_password: secret
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:
server_url: "http://zabbix.example.com/zabbix/"
login_user: admin
login_password: secret
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:
server_url: "http://zabbix.example.com/zabbix/"
login_user: admin
login_password: secret
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: “ACME” |
|
Discovery rule id. Returned: on success Sample: “42” |
|
The result of the operation Returned: always Sample: “Discovery rule created: ACME, ID: 42” |
|
Discovery rule state at the end of execution. Returned: on success Sample: “present” |
Authors
Tobias Birkefeld (@tcraxs)