community.zabbix
community.zabbix copied to clipboard
API configuration.import behavior changed in 5.4
Seems that Zabbix 5.4 has made something different as our CI is failing even after implementing #407.
Also read https://github.com/ansible-collections/community.zabbix/pull/407#issuecomment-869747870
Referenced template is https://github.com/ansible-collections/community.zabbix/blob/main/tests/integration/targets/test_zabbix_template/files/template1_52_higher.json
Now this is very interesting. If I FIRST upload template manually via Import
button in Zabbix GUI and then try to print template diff I get:
[]
Buut, if I run ansible-test integration test_zabbix_template
and then try to print template diff:
{
"templates": {
"added": [
{
"after": {
"template": "ExampleHost",
"name": "ExampleHost",
"macros": [
{
"macro": "{$EXAMPLE_MACRO1}",
"value": "1000"
},
{
"macro": "{$EXAMPLE_MACRO2}",
"value": "text"
}
],
"templates": [
{
"name": "FTP Service"
},
{
"name": "Zabbix Proxy"
}
],
"uuid": "c1a80829556941e4a1ff307b39130b5a"
}
}
]
}
}
This is my current test script:
import json
zbx = ZabbixAPI('http://localhost:8080')
zbx.login('Admin', 'zabbix')
update_rules = {
'discoveryRules': {
'createMissing': True,
'updateExisting': True,
'deleteMissing': True
},
'graphs': {
'createMissing': True,
'updateExisting': True,
'deleteMissing': True
},
'groups': {
'createMissing': True
},
'httptests': {
'createMissing': True,
'updateExisting': True,
'deleteMissing': True
},
'items': {
'createMissing': True,
'updateExisting': True,
'deleteMissing': True
},
'templates': {
'createMissing': True,
'updateExisting': True
},
'templateLinkage': {
'createMissing': True,
'deleteMissing': True
},
'templateDashboards': {
'createMissing': True,
'updateExisting': True,
'deleteMissing': True
},
'triggers': {
'createMissing': True,
'updateExisting': True,
'deleteMissing': True
},
'valueMaps': {
'createMissing': True,
'updateExisting': True
}
}
with open('tests/integration/targets/test_zabbix_template/files/template1_52_higher.json', 'r') as f:
source_json = json.load(f)
x = zbx.configuration.importcompare(dict(format='json', source=json.dumps(source_json), rules=update_rules))
print(json.dumps(x, indent=2))
zbx.logout()
Now I am lost :)
Originally posted by @D3DeFi in https://github.com/ansible-collections/community.zabbix/issues/407#issuecomment-869767750
Oh my, they have switched from using IDs to UUIDs! See #451
@D3DeFi I am assuming that this is no longer an issue?
Honestly I have no idea. But CI for zabbix_template is no longer failing and we are preparing to drop 5.4 as well, so lets ignore this and whoever finds this and disagrees can reopen :)