Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-15282

a specific template import via zabbix_template module in Ansible fails with HTTP 500

XMLWordPrintable

    • Icon: Incident report Incident report
    • Resolution: Duplicate
    • Icon: Trivial Trivial
    • None
    • 4.0.1
    • API (A)

      Steps to reproduce:

      1. Exported zabbix template for Linux OS'es (cfr. attachments)
      2. Import it via Ansible module zabbix_template

      Result:

      The Ansible playbook

       

      - hosts: test01
        gather_facts: no
        become: no
        tasks:
        - block:
          - name: Configure Linux OS template in Zabbix
            local_action:
              module: zabbix_template
              validate_certs: no
              server_url: "http://zabbix40/zabbix"
              login_user: "ansible"
              login_password: "mypasswordhere"
              template_name: "{{ item | basename | regex_replace('.json.j2','') }}"
              template_json: "{{ lookup('template', item) }}"
              timeout: 60
              state: present
            loop:
            - "Template_OS_Linux.json.j2"
          run_once: yes
      

       

      results in

       

      The full traceback is:
      Traceback (most recent call last):
        File "/tmp/ansible_zabbix_template_payload_RkCoRf/__main__.py", line 427, in import_template
          'rules': update_rules
        File "/usr/lib/python2.7/site-packages/zabbix_api.py", line 329, in method
          return self.universal("%s.%s" % (self.data["prefix"], name), opts[0])
        File "/usr/lib/python2.7/site-packages/zabbix_api.py", line 79, in wrapper
          return self.do_request(self.json_obj(method, opts))['result']
        File "/usr/lib/python2.7/site-packages/zabbix_api.py", line 336, in do_request
          return self.parent.do_request(req)
        File "/usr/lib/python2.7/site-packages/zabbix_api.py", line 255, in do_request
          raise APITimeout("HTTP read timeout",)
      APITimeout: HTTP read timeout
      
      failed: [ansible-t01 -> localhost] (item=Template_OS_Linux.json.j2) => {
          "changed": false, 
          "details": "HTTP read timeout", 
          "invocation": {
              "module_args": {
                  "clear_templates": null, 
                  "http_login_password": null, 
                  "http_login_user": null, 
                  "link_templates": null, 
                  "login_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                  "login_user": "ansible", 
                  "macros": null, 
                  "server_url": "http://zabbix04/zabbix", 
                  "state": "present"
                  ], 
                  "template_json": "{\"zabbix_export\": {\"templates\": [{\"templates\": [{\"name\": \"Template App Zabbix Agent\"}], \"description\": \"\", ...<<removed template output because of the text field limitation of 32767 characters in the issue creation form, cfr. attached template>> ..., \"version\": \"3.4\", \"groups\": [{\"name\": \"Templates\"}, {\"name\": \"Templates (Ansible-managed)\"}], \"date\": \"2018-09-13T08:58:49Z\"}}", 
                  "template_name": "Template_OS_Linux", 
                  "timeout": 60, 
                  "validate_certs": false
              }
          }, 
          "item": "Template_OS_Linux.json.j2", 
          "msg": "Unable to import JSON template"
      }
      

       

       

      I don't find anything that seems related in the zabbix server logs.

      Expected:
      The Ansible task results in Changed or OK meaning the template has been sucesfully imported or it already exists on the server:

       

      2018-11-11 13:21:02,374 p=46092 u=jan |  TASK [zabbixagent : Configure Linux OS template in Zabbix] *****************************************************************************************************************************************************************************
      2018-11-11 13:21:05,630 p=46092 u=jan |  ok: [ansible-t01 -> localhost] => (item=Template_OS_Linux.json.j2)
      

       

       

            zabbix.support Zabbix Support Team
            jan.vht Jan Verhaert
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: