ansible-collections/community.zabbix

Problem with host_groups argument.

Closed this issue · 4 comments

SUMMARY

Hi,
I try to create a host on zabbix,
If i put
host_groups:
- Linux
Error ask an groupid
If i put
host_groups:
- 22
Host_group dosen't find.

ISSUE TYPE
  • Bug Report
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\"}"

I have the same Problem sadly:

`

  • name: Add-host | Create a new host
    community.zabbix.zabbix_host:
    host_name: "{{ item }}"
    visible_name: "{{ item }}"
    description: "{{ dashboard.groupname }}"
    host_groups:
    - "{{ dashboard.groupname }}"
    link_templates:
    - "{{ item.split('.')[0] }}"
    - "Machine Specs"
    status: enabled
    state: present
    inventory_mode: manual
    inventory_zabbix:
    tag: ansible_add_host
    interfaces:
    - type: 1
    main: 1
    useip: 0
    dns: "{{ item }}"
    port: "10050"`

"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\"

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

#1190

@RayxiO and @Minimalistikaa does that solve your problems?

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 :)