Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zabbix_action - proxy.get - Invalid parameter "/filter": unexpected parameter "host". (Issue with proxy.get and zabbix 7.0) #1387

Closed
ben-dataraven opened this issue Sep 4, 2024 · 0 comments
Labels
bug Something isn't working module The issue or pull request is related to Zabbix module

Comments

@ben-dataraven
Copy link

SUMMARY

In filter expressions, zabbix_action.py still references the proxyname as host, where Zabbix 7.0 now expects the proxyname to be referenced as name (see https://www.zabbix.com/documentation/current/en/manual/api/changes, specifically api changes related to ZBXNEXT-8500)

This causes community.zabbix.zabbix_action to fail whenever it tries to lookup zabbix proxy details.

Changing "filter": {"host": [proxy_name]} to "filter": {"name": [proxy_name]} in zabbix_action.py (line 1018) "fixes" the issue

1018c1018
<                 "filter": {"host": [proxy_name]}
---
>                 "filter": {"name": [proxy_name]}
ISSUE TYPE
  • Bug Report
COMPONENT NAME

zabbix_action.py

ANSIBLE VERSION
ansible [core 2.14.14]
  config file = /home/ben/git/ansible/ansible.cfg
  configured module search path = ['/home/ben/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /home/ben/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.18 (main, Jul  3 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True
CONFIGURATION
CONFIG_FILE() = /home/ben/git/ansible/ansible.cfg
DEFAULT_JINJA2_EXTENSIONS(/home/ben/git/ansible/ansible.cfg) = jinja2.ext.do
OS / ENVIRONMENT / Zabbix Version

AlmaLinux 9
Zabbix 7.0

STEPS TO REPRODUCE

Use the community.zabbix.zabbix_action module to add an autoregistration action (based on zabbix_proxy)

- name: Prepare Zabbix Server for the Proxy (using the API)
  hosts: zabbix_proxies
  become: false
  vars:
    ansible_network_os: community.zabbix.zabbix
    ansible_connection: httpapi
    ansible_httpapi_port: 443
    ansible_httpapi_use_ssl: true
    ansible_host: "{{ zabbix_api_server_url }}"
    ansible_zabbix_url_path: ''
  tasks:
    - name: Setup autoregistration action to automatically populate zabbix groups
      community.zabbix.zabbix_action:
        name: "Add {{ zabbix_proxy_hostname }} autoregistered hosts to groups"
        event_source: auto_registration
        state: present
        status: enabled
        esc_period: 60
        conditions:
          - type: proxy
            operator: "="
            value: "{{ zabbix_proxy_hostname }}"
        operations:
          - type: add_to_host_group
            host_groups:
              - "Site/SITENAME"
EXPECTED RESULTS

The play succeeds

ACTUAL RESULTS

The play fails

The full traceback is:
  File "/tmp/ansible_community.zabbix.zabbix_action_payload_3zx5t1zu/ansible_community.zabbix.zabbix_action_payload.zip/ansible_collections/community/zabbix/plugins/module_utils/api_request.py", line 29, in _httpapi_error_handle
    code, response = self.connection.send_request(data=payload)
  File "/tmp/ansible_community.zabbix.zabbix_action_payload_3zx5t1zu/ansible_community.zabbix.zabbix_action_payload.zip/ansible/module_utils/connection.py", line 200, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [zabbix-proxy.dataraven.co.uk]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "acknowledge_operations": [],
            "conditions": [
                {
                    "formulaid": null,
                    "operator": "=",
                    "type": "proxy",
                    "value": "zabbix-proxy.dataraven.co.uk",
                    "value2": null
                }
            ],
            "esc_period": "60",
            "eval_type": null,
            "event_source": "auto_registration",
            "formula": null,
            "http_login_password": null,
            "http_login_user": null,
            "name": "Add zabbix-proxy.dataraven.co.uk autoregistered hosts to groups",
            "notify_if_canceled": true,
            "operations": [
                {
                    "command": null,
                    "command_type": null,
                    "esc_period": "0s",
                    "esc_step_from": 1,
                    "esc_step_to": 1,
                    "execute_on": null,
                    "host_groups": [
                        "Site/SITENAME"
                    ],
                    "inventory": null,
                    "media_type": "all",
                    "op_message": null,
                    "operation_condition": null,
                    "password": null,
                    "port": null,
                    "run_on_groups": null,
                    "run_on_hosts": null,
                    "script_name": null,
                    "send_to_groups": null,
                    "send_to_users": null,
                    "ssh_auth_type": null,
                    "ssh_privatekey_file": null,
                    "ssh_publickey_file": null,
                    "subject": null,
                    "templates": null,
                    "type": "add_to_host_group",
                    "username": null
                }
            ],
            "pause_in_maintenance": true,
            "pause_symptoms": true,
            "recovery_operations": [],
            "state": "present",
            "status": "enabled"
        }
    },
    "msg": "connection error occurred: REST API returned {'code': -32602, 'message': 'Invalid params.', 'data': 'Invalid parameter \"/filter\": unexpected parameter \"host\".'} when sending {\"jsonrpc\": \"2.0\", \"method\": \"proxy.get\", \"id\": \"IDNUMBER\", \"params\": {\"output\": \"extend\", \"filter\": {\"host\": [\"zabbix-proxy.dataraven.co.uk\"]}}, \"auth\": \"APIKEY\"}"
@pyrodie18 pyrodie18 added bug Something isn't working module The issue or pull request is related to Zabbix module labels Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module The issue or pull request is related to Zabbix module
Projects
None yet
Development

No branches or pull requests

2 participants