Updated zabbix_host module to support Zabbix 5.0 #51
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SUMMARY
Zabbix 5.0 support for
zabbix_host
module.Game breaking changes were:
hostinterface.get
now returnsdetails: []
for each interface type, even when not neededmacro.get
now returnstype: 0
for text macros and new typetype: 1
is for secret macrosvalue
property so there is no way to check if user wants tochange the value of macro. We can either always change it or require user to change something alongside it like
description
. I went with the later to not break idempotency of the module.Fixes #46
ISSUE TYPE
COMPONENT NAME
plugins/modules/zabbix_host.py
ADDITIONAL INFORMATION
I've finally added
options
forinterfaces
intomodule.argument_spec
. The downside is that ansible now prints warnings when type is an integer value as it is converted into a string:This was added in a good faith by me in the past (
interfaces[0]['type'] = 'agent'
). Users shouldn't need to bother with API details and it would make sense to change every numerical value to either bool or string in the future, but it cannot be done without breaking backwards compatibility.Just for example - we would have
interfaces[0]['main'] = True
instead ofinterfaces[0]['main'] = 1
. I don't know if this makes sense and if we want to pursue this in the future or if I should convertinterfaces[0]['type']
back to an integer.zabbix_action
is using this logic and doesn't use numerical values anywhere where it doesn't make sense.SNMP details are required, Zabbix documentation is broken - https://support.zabbix.com/browse/ZBX-17719
There is an additional issue, where
details
should be a dictionary and is accepted by an API as such. Whendetails
is empty, API returns empty list -details: []
instead, hence the conversion in the code to empty dict.