Description
SUMMARY
When trying to register an item with community.zabbix.zabbix_item directly on a HOST, an error occurs because the interfaceid isn't filled in in the API call to zabbix.
ISSUE TYPE
- Bug Report
COMPONENT NAME
community.zabbix.zabbix_item
ANSIBLE VERSION
ansible [core 2.18.1]
config file = /Users/wouter/Projects/stripped/ansible.cfg
configured module search path = ['/Users/wouter/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/11.1.0/libexec/lib/python3.13/site-packages/ansible
ansible collection location = /Users/wouter/Projects/stripped/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.13.1 (main, Dec 3 2024, 17:59:52) [Clang 16.0.0 (clang-1600.0.26.4)] (/opt/homebrew/Cellar/ansible/11.1.0/libexec/bin/python)
jinja version = 3.1.4
libyaml = True
CONFIGURATION
COLLECTIONS_PATHS(/Users/wouter/Projects/stripped/ansible.cfg) = ['/Users/wouter/Projects/stripped/collections']
CONFIG_FILE() = /Users/wouter/Projects/stripped/ansible.cfg
DEFAULT_FORKS(/Users/wouter/Projects/stripped/ansible.cfg) = 1
DEFAULT_HOST_LIST(/Users/wouter/Projects/stripped/ansible.cfg) = ['/Users/wouter/Projects/stripped/inventory.yaml']
DEFAULT_ROLES_PATH(/Users/wouter/Projects/stripped/ansible.cfg) = ['/Users/wouter/Projects/stripped/roles']
DEFAULT_STDOUT_CALLBACK(/Users/wouter/Projects/stripped/ansible.cfg) = yaml
PAGER(env: PAGER) = less
GALAXY_SERVERS:
OS / ENVIRONMENT / Zabbix Version
Zabbix version 7.2.4
Zabbix agent 2 version 7.2.4
Used version of community.zabbix is current master branch
STEPS TO REPRODUCE
---
- name: Register zabbix items
delegate_to: "{{ zabbix_hostname }}"
community.zabbix.zabbix_item:
name: "DNS: A: github.com"
host_name: "{{ inventory_hostname }}"
params:
key: net.dns.record[8.8.8.8,github.com,A,2,1]
type: zabbix_agent
value_type: text
interval: 1m
state: present
EXPECTED RESULTS
I'd expect an additional item to be created on the zabbix host with name {{ inventory_hostname }}
ACTUAL RESULTS
An error is shown that indicates that the parameter interfaceid is missing.
This is a required field if type is zabbix_agent and hostid is provided according to https://www.zabbix.com/documentation/current/en/manual/api/reference/item/object (and it has been required in older zabbix versions). It is not required if you're not providing a host but a templateid.
TASK [dcb.zabbix_configurer_items : Register zabbix items] ********************************************************************************************************************************************************************************************************************************************************
fatal: [dns-01 -> zabbix.stripped.hostname]: FAILED! => changed=false
msg: 'connection error occurred: REST API returned {''code'': -32602, ''message'': ''Invalid params.'', ''data'': ''Invalid parameter "/1": the parameter "interfaceid" is missing.''} when sending {''jsonrpc'': ''2.0'', ''method'': ''item.create'', ''id'': ''f5656960-4b2f-4cd4-97b9-3af717ff094e'', ''params'': {''type'': 0, ''value_type'': 4, ''name'': ''DNS: A: github.com'', ''key_'': ''net.dns.record[8.8.8.8,github.com,A,2,1]'', ''delay'': ''1m'', ''hostid'': ''10653''}}'
fatal: [dns-02 -> zabbix.stripped.hostname]: FAILED! => changed=false
msg: 'connection error occurred: REST API returned {''code'': -32602, ''message'': ''Invalid params.'', ''data'': ''Invalid parameter "/1": the parameter "interfaceid" is missing.''} when sending {''jsonrpc'': ''2.0'', ''method'': ''item.create'', ''id'': ''b7d2d30c-89c3-40cf-ac29-be944e73e853'', ''params'': {''type'': 0, ''value_type'': 4, ''name'': ''DNS: A: github.com'', ''key_'': ''net.dns.record[8.8.8.8,github.com,A,2,1]'', ''delay'': ''1m'', ''hostid'': ''10654''}}'
I do see the same behavior with key agent.version:
- name: Register zabbix items
delegate_to: "{{ zabbix_hostname }}"
community.zabbix.zabbix_item:
name: "agent version"
host_name: "{{ inventory_hostname }}"
params:
key: agent.version
type: zabbix_agent
value_type: text
interval: 1m
state: present
fatal: [dns-01 -> zabbix.stripped.hostname]: FAILED! => changed=false
msg: 'connection error occurred: REST API returned {''code'': -32602, ''message'': ''Invalid params.'', ''data'': ''Invalid parameter "/1": the parameter "interfaceid" is missing.''} when sending {''jsonrpc'': ''2.0'', ''method'': ''item.create'', ''id'': ''e778e806-244d-4a7e-80b6-55dcb607d30d'', ''params'': {''type'': 0, ''value_type'': 4, ''name'': ''agent version'', ''key_'': ''agent.version'', ''delay'': ''1m'', ''hostid'': ''10653''}}'
fatal: [dns-02 -> zabbix.stripped.hostname]: FAILED! => changed=false
msg: 'connection error occurred: REST API returned {''code'': -32602, ''message'': ''Invalid params.'', ''data'': ''Invalid parameter "/1": the parameter "interfaceid" is missing.''} when sending {''jsonrpc'': ''2.0'', ''method'': ''item.create'', ''id'': ''ebe23db8-7bf4-44ab-b140-fbdd72224f45'', ''params'': {''type'': 0, ''value_type'': 4, ''name'': ''agent version'', ''key_'': ''agent.version'', ''delay'': ''1m'', ''hostid'': ''10654''}}'