community.zabbix icon indicating copy to clipboard operation
community.zabbix copied to clipboard

Unable to create new template

Open latam-cse-dev opened this issue 2 years ago • 2 comments

SUMMARY

Unable to create a new template with module community.zabbix.zabbix_template.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

community.zabbix.zabbix_template

ANSIBLE VERSION
ansible [core 2.12.2]
  config file = /Users/draks/Documents/github/dev/mb-test-zabbix-gcp/debian-zabbix/ansible.cfg
  configured module search path = ['/Users/draks/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/5.3.0/libexec/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/draks/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.10.2 (main, Feb  2 2022, 08:42:42) [Clang 13.0.0 (clang-1300.0.29.3)]
  jinja version = 3.0.3
  libyaml = True
CONFIGURATION
CACHE_PLUGIN(/Users/draks/Documents/github/dev/mb-test-zabbix-gcp/debian-zabbix/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/Users/draks/Documents/github/dev/mb-test-zabbix-gcp/debian-zabbix/ansible.cfg) = .facts
DEFAULT_GATHERING(/Users/draks/Documents/github/dev/mb-test-zabbix-gcp/debian-zabbix/ansible.cfg) = smart
DEFAULT_HOST_LIST(/Users/draks/Documents/github/dev/mb-test-zabbix-gcp/debian-zabbix/ansible.cfg) = ['/Users/draks/Documents/github/d
DEFAULT_STDOUT_CALLBACK(/Users/draks/Documents/github/dev/mb-test-zabbix-gcp/debian-zabbix/ansible.cfg) = yaml
HOST_KEY_CHECKING(/Users/draks/Documents/github/dev/mb-test-zabbix-gcp/debian-zabbix/ansible.cfg) = False
INTERPRETER_PYTHON(/Users/draks/Documents/github/dev/mb-test-zabbix-gcp/debian-zabbix/ansible.cfg) = auto_silent
OS / ENVIRONMENT / Zabbix Version
root@zabbix-01:~# zabbix_server --version
zabbix_server (Zabbix) 6.0.1
Revision a80cb13868 1 March 2022, compilation time: Feb 27 2022 18:51:30

Copyright (C) 2022 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.

This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/).

Compiled with OpenSSL 1.1.1k  25 Mar 2021
Running with OpenSSL 1.1.1k  25 Mar 2021
STEPS TO REPRODUCE

Run the following playbook:

# Add host to zabbix
---
- hosts: zabbix
  tasks:
  - name: Create Zabbix template
    delegate_to: localhost
    community.zabbix.zabbix_template:
      server_url: "{{ server_url }}"
      login_user: "{{ login_user }}"
      login_password: "{{ login_password }}"
      template_name: ExampleHost
      template_groups:
        - 'Linux servers'
        - 'Templates'
      state: present
EXPECTED RESULTS

It should create a new template

ACTUAL RESULTS
TASK [Create Zabbix template] *******************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: zabbix_api.ZabbixAPIException: ('Error -32602: Invalid params., Invalid parameter "/1/templates": an array is expected. while sending {"jsonrpc": "2.0", "method": "template.create", "params": {"host": "ExampleHost", "groups": [{"groupid": "1"}, {"groupid": "2"}], "templates": null, "macros": null}, "auth": "63e2ea3fc094d4c4becec6b1151b6923", "id": 6}', -32602)
fatal: [zabbix -> localhost]: FAILED! => changed=false 
  module_stderr: |-
    Traceback (most recent call last):
      File "/Users/draks/.ansible/tmp/ansible-tmp-1647015232.878649-69738-11139078624097/AnsiballZ_zabbix_template.py", line 107, in <module>
        _ansiballz_main()
      File "/Users/draks/.ansible/tmp/ansible-tmp-1647015232.878649-69738-11139078624097/AnsiballZ_zabbix_template.py", line 99, in _ansiballz_main
        invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
      File "/Users/draks/.ansible/tmp/ansible-tmp-1647015232.878649-69738-11139078624097/AnsiballZ_zabbix_template.py", line 47, in invoke_module
        runpy.run_module(mod_name='ansible_collections.community.zabbix.plugins.modules.zabbix_template', init_globals=dict(_module_fqn='ansible_collections.community.zabbix.plugins.modules.zabbix_template', _modlib_path=modlib_path),
      File "/usr/local/Cellar/[email protected]/3.10.2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 209, in run_module
        return _run_module_code(code, init_globals, run_name, mod_spec)
      File "/usr/local/Cellar/[email protected]/3.10.2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 96, in _run_module_code
        _run_code(code, mod_globals, init_globals,
      File "/usr/local/Cellar/[email protected]/3.10.2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
        exec(code, run_globals)
      File "/var/folders/kg/7b8hsy0d2wd7q254wnppl_g40000gn/T/ansible_community.zabbix.zabbix_template_payload_5eqcmy4i/ansible_community.zabbix.zabbix_template_payload.zip/ansible_collections/community/zabbix/plugins/modules/zabbix_template.py", line 784, in <module>
      File "/var/folders/kg/7b8hsy0d2wd7q254wnppl_g40000gn/T/ansible_community.zabbix.zabbix_template_payload_5eqcmy4i/ansible_community.zabbix.zabbix_template_payload.zip/ansible_collections/community/zabbix/plugins/modules/zabbix_template.py", line 763, in main
      File "/var/folders/kg/7b8hsy0d2wd7q254wnppl_g40000gn/T/ansible_community.zabbix.zabbix_template_payload_5eqcmy4i/ansible_community.zabbix.zabbix_template_payload.zip/ansible_collections/community/zabbix/plugins/modules/zabbix_template.py", line 362, in add_template
      File "/usr/local/Cellar/ansible/5.3.0/libexec/lib/python3.10/site-packages/zabbix_api.py", line 341, in method
        return self.universal("%s.%s" % (self.data["prefix"], name), opts[0])
      File "/usr/local/Cellar/ansible/5.3.0/libexec/lib/python3.10/site-packages/zabbix_api.py", line 79, in wrapper
        return self.do_request(self.json_obj(method, opts))['result']
      File "/usr/local/Cellar/ansible/5.3.0/libexec/lib/python3.10/site-packages/zabbix_api.py", line 348, in do_request
        return self.parent.do_request(req)
      File "/usr/local/Cellar/ansible/5.3.0/libexec/lib/python3.10/site-packages/zabbix_api.py", line 299, in do_request
        raise ZabbixAPIException(msg, jobj['error']['code'])
    zabbix_api.ZabbixAPIException: ('Error -32602: Invalid params., Invalid parameter "/1/templates": an array is expected. while sending {"jsonrpc": "2.0", "method": "template.create", "params": {"host": "ExampleHost", "groups": [{"groupid": "1"}, {"groupid": "2"}], "templates": null, "macros": null}, "auth": "63e2ea3fc094d4c4becec6b1151b6923", "id": 6}', -32602)
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1

latam-cse-dev avatar Mar 11 '22 16:03 latam-cse-dev

Hi, I can't reproduce this issue using lastest stable version. Probably #633 fixed this issue.

mu1f407 avatar Jul 06 '22 11:07 mu1f407

@mu1f407 thanks for looking into!

@latam-cse-dev do you still experience this problem yourself?

D3DeFi avatar Jul 07 '22 12:07 D3DeFi

Issue inactive for a longer period now. I would assume that the comment from @mu1f407 was correct.

If you think otherwise, please feel free to re-open

D3DeFi avatar Aug 31 '22 15:08 D3DeFi