-
-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add code to ensure interfacedetails is always a hash #793
Add code to ensure interfacedetails is always a hash #793
Conversation
hey @oraziobattaglia, thanks for the PR. do you think there is an easy way to add tests for this? |
Hey @oraziobattaglia according to the API reference details is supposed to be an Array. Maybe it returns an array of hashes every time? |
Hi @root-expert me and my colleague working on this have seen that if interfacedetails has data the API returns an hash of data like
In case interfacedetails has no data the API returns an empty array like
I don't know why, maybe is a question related to the API, but the resource isn't idempotent. So the solution I found here is to declare a variant type for interfacedetails:
We also tried to declare interfacedetails as an array of hashes and seems to work fine too:
But in this second case I don't full understand how it works!! :-O Let me know if you have suggestions. |
I would say that this could be a Zabbix bug or incorrect documentation. Can you try raising an issue to their Jira before continuing further with this PR? The Variant solution seems okay to me. The
to the API is okay, or the API throws an error |
2aea5d4
to
8bd3e2c
Compare
Hi @root-expert seems it's a known bug, here they have similar problems with ansible ansible-collections/community.zabbix#51 |
e2ad733
to
24e2f88
Compare
The interface details as array of hashes doesn't work:
Puppet doesn't converge and there is always the error:
This is because, I think, there is a bug on the zabbix API. When interface details are given as hash the API returns an hash of data (not an array of hash). When interface details are not given the API returns an empty array []. I add a test, test4.example.com, that show that an empty interface details returns an empty array. If you have suggestions they are welcome! |
03f82da
to
ce21986
Compare
Pull Request (PR) description
This PR follow PR #785 to ensure the host object idempotency. When interface details are empty the zabbix API returns an empty array and I need to convert it in an empty hash.
Example
This is returned by the api call:
and the error on puppet is: