ansible-collections / community.zabbix

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

{''code'': -32602, ''message'': ''Invalid params.'', ''data'': ''Invalid parameter "/filter": unexpected parameter "host".''} #1377

Closed tl87 closed 2 months ago

tl87 commented 2 months ago

I'm well aware that there are few issues about this already, and the answer seems to be to make sure that the version of community.zabbix is >= 3.0.0. I've tried that and the error persists and why I'm creating this ticket.

SUMMARY

The problem:

msg: 'connection error occurred: REST API returned {''code'': -32602, ''message'': ''Invalid params.'', ''data'': ''Invalid parameter "/filter": unexpected parameter "host".''}

It use to work when using Zabbix version 6.4, but after an upgrade to Zabbix version 7.0.3, the issue has started.

ISSUE TYPE
COMPONENT NAME

Ansible module name: community.zabbix

ANSIBLE VERSION
ansible [core 2.17.3]
python version = 3.11.9
CONFIGURATION
- name: Create a new host in Zabbix
  vars:
    ansible_network_os: community.zabbix.zabbix
    ansible_connection: httpapi
    ansible_httpapi_port: 443
    ansible_httpapi_use_ssl: true
    ansible_httpapi_validate_certs: false
    ansible_host: XXXXXXX
    ansible_zabbix_url_path: ""
  become: false
  delegate_to: localhost
  community.zabbix.zabbix_host:
    force: true
    host_name: XXXXXXX
    visible_name: XXXXXXX
    description:
    host_groups:
      - Staging
    link_templates:
      - Windows by Zabbix agent active
    status: enabled
    state: present
    inventory_mode: automatic
    inventory_zabbix:
      tag:
      alias:
      notes:
      location:
      site_rack:
      os:
      hardware:
    ipmi_authtype:
    ipmi_privilege:
    ipmi_username:
    ipmi_password:
    interfaces:
      - type: 1
        main: 1
        useip: 0
        ip:
        dns: XXXXXXX
        port: 10050
    proxy: XXXXXXX
    state: "present"
    macros:
      - macro: OS
        value: Windows
    tags:
      - tag: target
        value: windows

- name: Update an existing host's TLS (ct01)
  vars:
    ansible_network_os: community.zabbix.zabbix
    ansible_connection: httpapi
    ansible_httpapi_port: 443
    ansible_httpapi_use_ssl: true
    ansible_httpapi_validate_certs: false
    ansible_zabbix_url_path: ""
    ansible_host: XXXXXXX
  become: false
  delegate_to: localhost
  community.zabbix.zabbix_host:
    host_name: XXXXXXX
    visible_name: XXXXXXX
    host_groups:
      - Staging
    tls_psk_identity: XXXXXXX
    tls_connect: 2
    tls_accept: 2
    tls_psk: XXXXXXX
    force: true
OS / ENVIRONMENT / Zabbix Version

Ansible is ran from Alpine Linux and target os is Windows server.

EXPECTED RESULTS

The host should be created on the Zabbix server, but it does not happen.

ACTUAL RESULTS
The full traceback is:
File "/tmp/ansible_community.zabbix.zabbix_host_payload_30e4tdrq/ansible_community.zabbix.zabbix_host_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_host_payload_30e4tdrq/ansible_community.zabbix.zabbix_host_payload.zip/ansible/module_utils/connection.py", line 199, in __rpc__
  raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)

fatal: [XXXXXXX -> XXXXXXX(XXXXXXX)]: FAILED! => changed=false 
invocation:
  module_args:
    ca_cert: null
    description: null
    force: true
    host_groups:
    - Staging
    host_name: XXXXXXX
    http_login_password: null
    http_login_user: null
    interfaces:
    - details: {}
      dns: XXXXXXX
      ip: ''
      main: 1
      port: '10050'
      type: 1
      useip: 0
    inventory_mode: automatic
    inventory_zabbix:
      alias: null
      hardware: null
      location: null
      notes: null
      os: null
      site_rack: null
      tag: null
    ipmi_authtype: null
    ipmi_password: null
    ipmi_privilege: null
    ipmi_username: null
    link_templates:
    - Windows by Zabbix agent active
    macros:
    - description: ''
      macro: '{$OS}'
      type: '0'
      value: Windows
    proxy: XXXXXXX
    state: present
    status: enabled
    tags:
    - tag: target
      value: windows
    tls_accept: null
    tls_connect: null
    tls_psk: null
    tls_psk_identity: null
    tls_subject: null
    visible_name: XXXXXXX
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": "XXXXXXX", "params": {"output": "extend", "filter": {"host": ["XXXXXXX"]}}, "auth": "XXXXXXX"}'
BGmot commented 2 months ago

You are not using the latest version of this collection.

tl87 commented 2 months ago

Updating helped.

I've specified version 3.1.1 in the Ansible collections file called 'requirements.yml':

---
collections:
  - name: community.zabbix
    version: ">=3.1.1"
ben-dataraven commented 1 month ago

I'm still getting this issue on version 3.1.1

It looks like the filter is expecting name rather than host