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

variable ansible_zabbix_url_path does not work

Open drMARTINS13 opened this issue 1 year ago • 22 comments

SUMMARY

We have zabbix sitting on simple subdomain zabbix.example.com and when we want add something to zabbix via ansible we get this error The error was: ansible.module_utils.connection.ConnectionError: Invalid JSON response: File not found So I know that ansible call zabbix.example.com/zabbix/api_jsonrpc.php. I add to inventory variable ansible_zabbix_url_path (i tried "/" and "") and still same problem. When i try curl zabbix.example.com/api_jsonrpc.php i get valid response.

We think problem is here https://github.com/ansible-collections/community.zabbix/blob/56f94d151da34b71a1a09af0b4eca6c7ddee319b/plugins/httpapi/zabbix.py#L132

ISSUE TYPE
  • Bug Report
COMPONENT NAME

TASK [community.zabbix.zabbix_agent : API | Create host groups] but it is also in another tasks that call api_jsonrpc.php

ANSIBLE VERSION

ansible [core 2.14.4] community.zabbix 1.9.3 (tried also 1.9.2)

OS / ENVIRONMENT / Zabbix Version

Zabbix server 6.4

STEPS TO REPRODUCE

Install zabbix on subdomain for example zabbix.example.com Run ansible with invetory file ... server001: install_zabbix_agent: True zabbix_api_create_hosts: True zabbix_api_create_hostgroup: True zabbix_agent2: True zabbix_agent_package_remove: True zabbix_agent2_server: zabbix-proxy.example.com zabbix_agent2_serveractive: zabbix-proxy.example.com zabbix_agent_proxy: zabbix-proxy.example.com zabbix_api_server_host: zabbix.example.com ansible_zabbix_url_path: "" zabbix_host_groups: - MAINGROUP - MAINGROUP/SUBGROUP zabbix_agent_link_template: - Template OS Linux by Zabbix agent - Template Check security updates via APT - Template Module ICMP Ping

role/task/main.yml

  • name: Installing Zabbix Agent include_role: name: community.zabbix.zabbix_agent .....
EXPECTED RESULTS

Server001 is registered to zabbix server, is in groups and has templates

ACTUAL RESULTS

TASK [community.zabbix.zabbix_agent : API | Create host groups] ********************************************************************************************** FAILED - RETRYING: [server001 -> zabbix.example.com]: API | Create host groups (3 retries left). FAILED - RETRYING: [server001 -> zabbix.example.com]: API | Create host groups (2 retries left). FAILED - RETRYING: [server001-> zabbix.example.com]: API | Create host groups (1 retries left). An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.module_utils.connection.ConnectionError: Invalid JSON response: File not found.

drMARTINS13 avatar Apr 24 '23 10:04 drMARTINS13