community / community.zabbix / 1.8.0 / module / zabbix_discovery_rule Create/delete/update Zabbix discovery rules Authors: Tobias Birkefeld (@tcraxs)community.zabbix.zabbix_discovery_rule (1.8.0) — module
Install with ansible-galaxy collection install community.zabbix:==1.8.0
collections: - name: community.zabbix version: 1.8.0
Create discovery rule.
Delete existing discovery rule.
Update existing discovery rule with new options.
# 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
name: description: - Name of the discovery rule. required: true type: str delay: default: 1h description: - Execution interval of the discovery rule. - Accepts seconds, time unit with suffix and user macro. type: str proxy: description: - Name of the proxy used for discovery. type: str state: choices: - present - absent default: present description: - Create or delete discovery rules. type: str status: choices: - enabled - disabled default: enabled description: - Whether the discovery rule is enabled. - 'Possible values:' - enabled (default) - disabled type: str dchecks: aliases: - dcheck description: - List of dictionaries of discovery check objects. - For more information, review discovery check object documentation at U(https://www.zabbix.com/documentation/current/manual/api/reference/dcheck/object) elements: dict suboptions: host_source: choices: - DNS - IP - discovery default: DNS description: - Source for host name. - 'Possible values:' - DNS (default) - IP - discovery - discovery value of this check - Options is available since Zabbix 4.4 type: str key: description: - 'The value of this property differs depending on the type of the check:' - '- key to query for Zabbix agent checks' - '- SNMP OID for SNMPv1, SNMPv2 and SNMPv3 checks' type: str name_source: choices: - None - DNS - IP - discovery default: None description: - 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 type: str ports: description: - One or several port ranges to check separated by commas. Used for all checks except for ICMP. type: str snmp_community: description: - SNMP community. - Required for SNMPv1 and SNMPv2 agent checks. type: str snmpv3_authpassphrase: description: - Authentication passphrase used for SNMPv3 agent checks with security level set to authNoPriv or authPriv. type: str snmpv3_authprotocol: choices: - MD5 - SHA description: - Authentication protocol used for SNMPv3 agent checks with security level set to authNoPriv or authPriv. - 'Possible values:' - MD5 - SHA type: str snmpv3_contextname: description: - SNMPv3 context name. Used only by SNMPv3 checks. type: str snmpv3_privpassphrase: description: - Privacy passphrase used for SNMPv3 agent checks with security level set to authPriv. type: str snmpv3_privprotocol: choices: - DES - AES description: - Privacy protocol used for SNMPv3 agent checks with security level set to authPriv. - 'Possible values:' - DES - AES type: str snmpv3_securitylevel: choices: - noAuthNoPriv - authNoPriv - authPriv description: - Security level used for SNMPv3 agent checks. - 'Possible values:' - noAuthNoPriv - authNoPriv - authPriv type: str snmpv3_securityname: description: - Security name used for SNMPv3 agent checks. type: str type: choices: - SSH - LDAP - SMTP - FTP - HTTP - POP - NNTP - IMAP - TCP - Zabbix - SNMPv1 - SNMPv2 - ICMP - SNMPv3 - HTTPS - Telnet description: - Type of check. type: str uniq: default: false description: - 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 type: bool type: list iprange: description: - One or several IP ranges to check separated by commas. elements: str type: list timeout: default: 10 description: - The timeout of API request (seconds). type: int login_user: description: - Zabbix user name. - If not set the environment variable C(ZABBIX_USERNAME) will be used. required: true type: str server_url: aliases: - url description: - URL of Zabbix server, with protocol (http or https). C(url) is an alias for C(server_url). - If not set the environment variable C(ZABBIX_SERVER) will be used. required: true type: str login_password: description: - Zabbix user password. - If not set the environment variable C(ZABBIX_PASSWORD) will be used. required: true type: str validate_certs: default: true description: - 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 C(ZABBIX_VALIDATE_CERTS) will be used. type: bool http_login_user: description: - Basic Auth login type: str http_login_password: description: - Basic Auth password type: str
drule: description: Discovery rule name. returned: on success sample: ACME type: str druleid: description: Discovery rule id. returned: on success sample: '42' type: str msg: description: The result of the operation returned: always sample: 'Discovery rule created: ACME, ID: 42' type: str state: description: Discovery rule state at the end of execution. returned: on success sample: present type: str