[ZBX-19486] Import template by API successful response but no hosts row Created: 2021 May 28 Updated: 2021 Jun 07 Resolved: 2021 Jun 07 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | API (A) |
Affects Version/s: | 5.4.0 |
Fix Version/s: | None |
Type: | Problem report | Priority: | Trivial |
Reporter: | Josh | Assignee: | Igor Gorbach (Inactive) |
Resolution: | Won't fix | Votes: | 0 |
Labels: | None | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Attachments: |
![]() |
Description |
Steps to reproduce: **Make any valid template. Here's a super-simple TEST: {{{{ "zabbix_export": { "groups": [ { "name": "Zabbix servers", "uuid": "6f6799aa69e844b4b3918f779f2abf08" }], "templates": [ { "groups": [ { "name": "Zabbix servers" }], "name": "TEST", "template": "TEST", "uuid": "e4ad7acc1a804011b7b8161663e1f31b" } ], "version": "5.4" }}}}
++Import (in my case with Ansible) - I am NOT using the zabbix_template module which right now seems to be broken with 5.4, because they are still trying to set "applications" Ansible task for reference: {norformat}- name: Zabbix API - Import template uri: url: "https://{{ cert_domain }}.{{ domain }}/api_jsonrpc.php" method: POST body: "{{ lookup('template','/etc/ansible/enlite/files/zabbix/template.import.test.json.j2') }}" body_format: json return_content: yes register: api_result failed_when: "'error' in api_result.content" - debug: var: api_result{norformat} and template.import.test.json.j2 contents: { "jsonrpc": "2.0", "method": "configuration.import", "params": { "format": "xml", "rules": { "valueMaps": { "createMissing": true, "updateExisting": false }, "hosts": { "createMissing": true, "updateExisting": true }, "items": { "createMissing": true, "updateExisting": true, "deleteMissing": true } }, "source": "<zabbix_export><version>5.4</version><groups><group><uuid>f2481361f99448eea617b7b1d4765566</uuid><name>Discovered hosts</name></group></groups><templates><template><uuid>62925bc2fc844fa6a531cbb6d5515d65</uuid><template>TEST</template><name>TEST</name><groups><group><name>Discovered hosts</name></group></groups></template></templates></zabbix_export>" }, "auth": "{{ auth_token }}", "id": 1 } Result: SEEMS successful: {norformat}"json": { "id": 1, "jsonrpc": "2.0", "result": true }{norformat}
Full Ansible task output: {norformat}TASK [Zabbix API - Import template] ******************************************** ok: [localhost] TASK [debug] ******************************************************************* ok: [localhost] => { "api_result": { "access_control_allow_headers": "Content-Type", "access_control_allow_methods": "POST", "access_control_allow_origin": "*", "access_control_max_age": "1000", "changed": false, "connection": "close", "content": "{\"jsonrpc\":\"2.0\",\"result\":true,\"id\":1}", "content_security_policy_report_only": "default-src https:; script-src https: 'unsafe-eval' 'unsafe-inline'; style-src https: 'unsafe-inline'; img-src https: data:; font-src https: data:; report-uri /csp-report", "content_type": "application/json", "cookies": {}, "cookies_string": "", "date": "Fri, 28 May 2021 18:21:29 GMT", "elapsed": 0, "failed": false, "failed_when_result": false, "json": { "id": 1, "jsonrpc": "2.0", "result": true }, "msg": "OK (unknown bytes)", "redirected": false, "server": "nginx", "status": 200, "strict_transport_security": "max-age=31536000; preload", "transfer_encoding": "chunked", "url": "https://dev-monitor.intertalk.cloud/api_jsonrpc.php", "x_powered_by": "PHP/7.4.19" } }{norformat}
However, no template was imported. This is best reflected in the DB: {norformat}mysql> select * from hosts where uuid = 'e4ad7acc1a804011b7b8161663e1f31b'; Empty set (0.00 sec){norformat}
But of course you can see this in the GUI by the lack of the "TEST" template: Expected: NOTES:
|
Comments |
Comment by Igor Gorbach (Inactive) [ 2021 Jun 07 ] |
Hello! ZBX - is a bug tracker for identifying and fix some issues in Zabbix functionality Read carefully paramaters description or |