Closed D3DeFi closed 2 years ago
@D3DeFi thanks for creating an issue. Internally I fixed it in another way than in original PR. Successful tests, where I saw that template linking is used, is exactly what makes me curious as well. I wanted to run tests against Zabbix 5.0 before submitting another PR, but I will need some time to prepare the test environment.
I've managed to install Docker testing environment and I found that it fails only on template.create API call and there is no test which could catch this error, because the template create test does not links any templates.
I added another test for create with linked templates and it fails:
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: zabbix_api.ZabbixAPIException: ('Error -32500: Application error., No permissions to referred object or it does not exist! while sending {"jsonrpc": "2.0", "method": "template.create", "params": {"host": "ExampleHostWithLinked", "groups": [{"groupid": "1"}, {"groupid": "2"}], "templates": ["10048", "10093"], "macros": null}, "auth": "0150fb7d8f1b8e2caafa73da969bddb5", "id": 8}', -32500)
I think it would be best to fix the template.update according to API docs as well. Even if it doesn't fail now, because it could in the future. I will try to send a PR this week with added create test with linked templates and fixed linked templates handling for create and update calls.
@mu1f407 awesome! Thank you :) I will then assign this issue to you
SUMMARY
See #518
Apparently, we link templates in a wrong way?
I wonder why our zabbix_template module even works in actual state, since doc for 4.0 also notes using
templates: [templateid: val]
ISSUE TYPE
COMPONENT NAME
plugins/modules/zabbix_template.py