ansible-collections / community.zabbix

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

Templates to link are never found #340

Closed rhaamo closed 3 years ago

rhaamo commented 3 years ago
SUMMARY

When using zabbix_link_templates templates are not found.

ISSUE TYPE
COMPONENT NAME

role zabbix_agent

ANSIBLE VERSION
ansible 2.10.6
  config file = /home/dashie/dev/ansible/ansible.cfg
  configured module search path = ['/home/dashie/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/dashie/.local/lib/python3.8/site-packages/ansible
  executable location = /home/dashie/.local/bin/ansible
  python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
CONFIGURATION
ANSIBLE_PIPELINING(/home/dashie/dev/ansible/ansible.cfg) = True
DEFAULT_HASH_BEHAVIOUR(/home/dashie/dev/ansible/ansible.cfg) = merge
DEFAULT_HOST_LIST(/home/dashie/dev/ansible/ansible.cfg) = ['/home/dashie/dev/ansible/hosts.ini']
DEFAULT_PRIVATE_KEY_FILE(/home/dashie/dev/ansible/ansible.cfg) = /home/dashie/dev/ansible/.ssh/id_rsa
DEFAULT_REMOTE_USER(/home/dashie/dev/ansible/ansible.cfg) = ansible
DEFAULT_ROLES_PATH(/home/dashie/dev/ansible/ansible.cfg) = ['/home/dashie/dev/ansible/roles']
DEFAULT_TRANSPORT(/home/dashie/dev/ansible/ansible.cfg) = ssh
HOST_KEY_CHECKING(/home/dashie/dev/ansible/ansible.cfg) = False
INTERPRETER_PYTHON(/home/dashie/dev/ansible/ansible.cfg) = auto_silent
RETRY_FILES_SAVE_PATH(/home/dashie/dev/ansible/ansible.cfg) = /home/dashie/dev/ansible/retries
OS / ENVIRONMENT / Zabbix Version

Zabbix 5.2.5

STEPS TO REPRODUCE
# playbook
  roles:
      - role: zabbix_agent
        zabbix_agent_server: "{{ zabbix_server }}"
        zabbix_agent_serveractive: "{{ zabbix_server }}"
        zabbix_agent2: true
        zabbix_agent2_hostname: "{{ hostname }}"
        zabbix_url: "https://xxx"
        zabbix_api_create_hosts: true
        zabbix_api_use: true
        zabbix_api_user: "xxx"
        zabbix_api_pass: "xxx"
        zabbix_link_templates: "{{ zabbix_templates }}"
        zabbix_host_groups: "{{ zabbix_groups }}"
        zabbix_inventory_mode: 'automatic'
# host vars
zabbix_templates:
    - Linux by Zabbix agent
EXPECTED RESULTS

Template should be found

ACTUAL RESULTS

When going into Configuration/Templates I can definitely see a template with template name as "Linux by Zabbix agent", but when using ansible, it can't find it:

fatal: [xxx]: FAILED! => {"attempts": 3, "changed": false, "msg": "Template not found: Linux by Zabbix agent"}

Same with Docker on another host:

fatal: [yyy]: FAILED! => {"attempts": 3, "changed": false, "msg": "Template not found: Docker"}
rhaamo commented 3 years ago

Ok so after more tests, zabbix permissions using the API are weird, by default Admin or even Super Admin can't do anything with the templates/host groups, and you have to specifically create an User group and assign permissions to your Templates* and various host groups you wants to use/link/...