ansible-collections / community.zabbix

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

Problem with host_groups argument. #1364

Closed RayxiO closed 1 month ago

RayxiO commented 2 months ago
SUMMARY

Hi, I try to create a host on zabbix, If i put host_groups:

ISSUE TYPE
COMPONENT NAME

community.zabbix.zabbix_host

ANSIBLE VERSION
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.1.4
  libyaml = True
CONFIGURATION
CONFIG_FILE() = /etc/ansible/ansible.cfg
OS / ENVIRONMENT / Zabbix Version

Debian 12 / Zabbix 7.0.2

STEPS TO REPRODUCE
---
- name: Set credentials Zabbix Server API
  ansible.builtin.set_fact:
    ansible_network_os: "{{ zbx_network_os }}"
    ansible_connection: "{{ zbx_connection }}"
    ansible_httpapi_port: "{{ zbx_httpapi_port }}"
    ansible_user: "{{ zbx_httpapi_user }}"
    ansible_httpapi_pass: "{{ zbx_httpapi_pass }}"
    ansible_httpapi_use_ssl: "{{ zbx_httpapi_use_ssl }}" 
    ansible_httpapi_validate_certs: "{{ zbx_httpapi_validate_certs }}"
    ansible_host: "{{ zbx_host }}"
    ansible_zabbix_url_path: "{{ zbx_path }}"

- name: Creation of Hosts.
  community.zabbix.zabbix_host:
    host_name: test
    visible_name: test
    host_groups: 
    - Linux
    link_templates:
    - "Linux by Zabbix agent"
    status: enabled
    state: present
    inventory_mode: manual
    inventory_zabbix:
      tag: "{{ zbx_tag }}"
      os: "{{ os_debian12 }}"
    interfaces:
      - type: 1
        main: 1
        useip: 1
        ip: ....
        port: "10050"
###Problem with host groups
EXPECTED RESULTS

Creation of the host test with the group linux

ACTUAL RESULTS
"msg": "connection error occurred: REST API returned {'code': -32602, 'message': 'Invalid params.', 'data': 'Invalid parameter \"/1/groups/1\": unexpected parameter \"name\".'} when sending {\"jsonrpc\": \"2.0\", \"method\": \"host.create\", \"id\": \"d3c512b1-fb03-44a0-9ce2-e61a884200b9\", \"params\": {\"host\": \"test\", \"interfaces\": [{\"type\": 1, \"main\": 1, \"useip\": 1, \"ip\": \"10.x.x.x\", \"port\": \"10050\", \"details\": {}, \"dns\": \"\"}], \"groups\": [{\"groupid\": \"22\", \"name\": \"Linux\", \"flags\": \"0\", \"uuid\": \"efe3710309fa40d2bde7cf1db98859b2\"}], \"status\": 0, \"name\": \"test\"}, \"auth\": \"ada89a103aa0d634dc5c20d419dba4b0\"}"
Minimalistikaa commented 2 months ago

I have the same Problem sadly:

`

"msg": "connection error occurred: REST API returned {'code': -32602, 'message': 'Invalid params.', 'data': 'Invalid parameter \"/1/groups/1\": unexpected parameter \"name\".'} when sending {\"jsonrpc\": \"2.0\", \"method\": \"host.create\"

bastidest commented 2 months ago

stumbled over this too, make sure you are using collection version >= 3.0.0 with Zabbix 7

1190

pyrodie18 commented 2 months ago

@RayxiO and @Minimalistikaa does that solve your problems?

RayxiO commented 1 month ago

Hello,

stumbled over this too, make sure you are using collection version >= 3.0.0 with Zabbix 7

1190

I was not in 3.x after upgrade all is good. thanks for your help :)