Closed pyrodie18 closed 1 month ago
I confirm this issue. It appeared with Zabbix Frontend 7.0.1. Ansible code:
- zabbix_host:
host_name: '{{ zabbix_agent_hostname }}'
tls_accept: 2 # PSK
tls_connect: 2 # PSK
tls_psk: '{{ zabbix_agent2_tlspsk_secret }}'
tls_psk_identity: '{{ zabbix_agent_hostname }}'
Error (reformatted):
fatal: [host -> zabbix.example.com]: FAILED! =>
changed: false
msg: 'connection error occurred: REST API returned {''code'': -32602, ''message'':
''Invalid params.'', ''data'': ''Incorrect arguments passed to function.''} when
sending:
{
"jsonrpc": "2.0",
"method": "host.update",
"id": "1a48c4c6-f48a-49de-8aad-10887697bc5e",
"params": {
"hostid": "10188",
"groups": [
{
"groupid": "28"
}
],
"status": 0,
"monitored_by": 0,
"tls_connect": 2,
"tls_accept": 2,
"tls_psk_identity": "xxx",
"tls_psk": "********",
"interfaces": [
{
"main": 1,
"useip": 1,
"ip": "xx.xx.xx.xx",
"dns": "",
"port": "10050",
"interfaceid": "30204",
"hostid": "10188",
"type": 1,
"available": "1",
"error": "",
"errors_from": "0",
"disable_until": "0",
"details": {
"version": 2,
"bulk": 1,
"community": "",
"securityname": "",
"contextname": "",
"securitylevel": 0,
"authprotocol": 0,
"authpassphrase": "",
"privprotocol": 0,
"privpassphrase": ""
}
}
]
},
"auth": "xxx"
}
Seems the cause is the fix: "The "error" field must be read-only, but it is possible to set a value for this field when creating a network discovery rule" that added this check: https://git.zabbix.com/projects/ZBX/repos/zabbix/commits/3d5a48d327ec01a4c8e58460873297f9b56f576e#ui/include/classes/api/services/CHostInterface.php:
$allowed_fields = array_flip([
'hostid', 'type', 'ip', 'dns', 'port', 'useip', 'main', 'details', 'interface_ref', 'items', 'interfaceid'
]);
...
if (!check_db_fields($interfaceDBfields, $interface) || array_diff_key($interface, $allowed_fields)) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect arguments passed to function.'));
}
We have a bug and for an unknown reason we are passing in API call extra read-only fields: "available": "1", "error": "", "errors_from": "0", "disable_until": "0", "details":{...}
Need to remove this useless fields from an API call to host.update
.
Workaround: for any zabbix_host
specify block interfaces
:
- zabbix_host:
host_name: '{{ zabbix_agent_hostname }}'
tls_accept: 2 # PSK
tls_connect: 2 # PSK
tls_psk: '{{ zabbix_agent2_tlspsk_secret }}'
tls_psk_identity: '{{ zabbix_agent_hostname }}'
interfaces:
- type: agent
main: 1
useip: 1
ip: '{{ ansible_host }}'
port: '{{ zabbix_agent_port }}'
In this case no extra parameters will be passed.
yesterday zabbix 7.0.2 was released.
the bug ist closed with this version on zabbix site
I've tested versions 7.0.1 and 7.0.2, both have this issue, additional validation added in 7.0.1.
I spent some time looking around yesterday and don't see where those values are even being added into the API call. Unfortunately @BGmot is a lot better with the module stuff then me.
I understood how to resolve, so I wrote commit to fix. @BGmot If I offend you, I apologize for creating PR although you were assigned.
I assigned it to him since he's the one that normally does it....Don't think he's even seen it yet so I'm sure no offense taken.
I've tested versions 7.0.1 and 7.0.2, both have this issue, additional validation added in 7.0.1.
ah ok. thanks for the workaround with the interface ...this works for me
SUMMARY
Not sure what happened but at some point in the last two weeks the host module started breaking. The last plugin-integration test to run (https://github.com/ansible-collections/community.zabbix/actions/runs/9933607178/job/28017631838) ran 100% all the way through (NOTE: The failure there now is one that I triggered today to see if it still passed like it had previously). @masa-orca discovered this failure with #1353.
Failure read-out:
It looks like Zabbix dropped 7.0.1 in the last week or two but the change doesn't doesn't mention the host API at all so not sure what changed.
ISSUE TYPE
COMPONENT NAME
zabbix_host module on Zabbix 7.0