ansible-collections / community.zabbix

Zabbix Ansible modules
http://galaxy.ansible.com/community/zabbix
Other
322 stars 284 forks source link

zabbix_template: incorrect export and import of non-ACSII strings in template [bug] #28

Closed sky-joker closed 3 years ago

sky-joker commented 4 years ago

From @selivan on 17 Apr 2019

SUMMARY

When Zabbix template is saved using state=dump of module zabbix_template, all non-ASCII strings become encoded like this: "\u0422\u0435\u0441\u0442"(this is Russian string "Тест"). On importing this template using state=present, trigger name presented by this string becomes "\u0422\u0435\u0441\u0442" instead of "Тест".

ISSUE TYPE
COMPONENT NAME

zabbix_template

ANSIBLE VERSION
ansible 2.7.10
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.15rc1 (default, Nov 12 2018, 14:31:15) [GCC 7.3.0]
CONFIGURATION
ANSIBLE_NOCOWS(/home/user/work/ansible/ansible.cfg) = True
ANSIBLE_PIPELINING(/home/user/work/ansible/ansible.cfg) = True
OS / ENVIRONMENT

OS: Ubuntu 16.04 Xenial Zabbix Server: 4.0

STEPS TO REPRODUCE
- name: Dump Zabbix template
  local_action:
    module: zabbix_template
    server_url: "{{ zabbix_server_url }}"
    login_user: "{{ zabbix_user }}"
    login_password: "{{ zabbix_password }}"
    template_name: "t_test"
    state: dump
  register: template_dump

- name: Save json template
  local_action:
    module: copy
    content: "{{ template_dump['template_json'] }}"
    dest: t_test.json

- name: Import Zabbix Template
  zabbix_template:
    server_url: "{{ zabbix_server_url }}"
    login_user: "{{ zabbix_user }}"
    login_password: "{{ zabbix_password }}"
    template_name: "t_test"
    template_groups:
       - Templates
    state: present
    template_json: "{{ lookup('file', 't_test.json') }}"
EXPECTED RESULTS

Non-ASCII characters in template, like trigger names, should be restored correctly.

ACTUAL RESULTS

Non-ASCII characters in template, like trigger names, are restored in this form: \u0422\u0435\u0441\u0442"/

Copied from original issue: https://github.com/ansible/ansible/issues/55439

D3DeFi commented 4 years ago

@selivan commented:

If someone struggles with the same bug and finds this issue, here is a quick and ugly workaround:

local action: shell cat {{t_name}}.json.raw | sed 's/\\\\u/\\u/g' > {{t_name}}.json

Problem analysed in the comment before.

D3DeFi commented 3 years ago

After conducting testing I believe this is the same issue as reported in #225 and will also be fixed by PR #226