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

host.create with SNMP interface not working with Zabbix 5.0 #46

Closed
toerb opened this issue May 13, 2020 · 5 comments · Fixed by #51
Closed

host.create with SNMP interface not working with Zabbix 5.0 #46

toerb opened this issue May 13, 2020 · 5 comments · Fixed by #51
Assignees
Labels
bug Something isn't working module The issue or pull request is related to Zabbix module

Comments

@toerb
Copy link

toerb commented May 13, 2020

SUMMARY

Zabbix 5.0 introduced a change in the host interface handling. The new documentation mentions a new details parameter which is used only for SNMP interfaces.

In order to create a new host with a SNMP interface this new property has to be set. Unfortunately the documentation seems to be not clear about which fields are mandatory and which are optional. There is ZBX-17719 handling this topic.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

zabbix_host

ANSIBLE VERSION
ansible 2.9.6
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /root/ansible/.venv/lib/python3.6/site-packages/ansible
  executable location = /root/ansible/.venv/bin/ansible
  python version = 3.6.8 (default, Aug  7 2019, 17:28:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
CONFIGURATION

OS / ENVIRONMENT
STEPS TO REPRODUCE

I am trying to create zabbix hosts for our HPE iLOs. They are being monitored via SNMP.
For this procedure I am using the following task in an ansible playbook.

  zabbix_host:
    server_url: '{{ monitoring_server }}'
    login_user: '{{ monitoring_user }}'
    login_password: '{{ monitoring_password }}'
    host_name: '{{ ilo_ip }}'
    visible_name: '{{ dns_fqdn }}'
    host_groups: '{{ monitoring_groups | default(["iLO"]) }}'
    link_templates: '{{ monitoring_templates | default(["Template Server HP iLO SNMPv2"]) }}'
    interfaces:
    - type: 2
      main: 1
      useip: 1
      ip: '{{ ilo_ip }}'
      dns: ""
    status: '{{ monitoring_status | default("enabled") }}'
    state: '{{ monitoring_state | default("present") }}'
    validate_certs: no
EXPECTED RESULTS

The playbook should create the host. That has worked on Zabbix 4.4, while it is not working on Zabbix 5.0.

ACTUAL RESULTS

I get an error stating "Error -32602: Invalid params., Incorrect arguments passed to function."

fatal: [*** -> ***]: FAILED! => {"changed": false, "msg": "Failed to create host ***: ('Error -32602: Invalid params., Incorrect arguments passed to function. while sending {\"jsonrpc\": \"2.0\", \"method\": \"host.create\", \"params\": {\"host\": \"***\", \"interfaces\": [{\"type\": 1, \"main\": 1, \"useip\": 1, \"ip\": \"127.0.0.1\", \"dns\": \"\", \"port\": \"10050\"}, {\"type\": 2, \"main\": 1, \"useip\": 1, \"ip\": \"***\", \"dns\": \"\", \"port\": \"161\"}], \"groups\": [{\"groupid\": \"22\"}], \"status\": 0, \"tls_connect\": 1, \"tls_accept\": 1, \"name\": \"***\"}, \"auth\": \"***\", \"id\": 5}', -32602)"}
@JohannesKreuzer
Copy link

This is the structure needed for creating a host with snmp interface in Zabbix 5.0:

          {
                "dns": "",
                "ip": "10.20.100.148",
                "main": 1,
                "port": "161",
                "type": 2,
                "useip": 1,
                "details": {
                	"version": 2,
                	"community": "public"
                }
            }

@D3DeFi
Copy link
Contributor

D3DeFi commented May 13, 2020

Hey guys, thanks for reporting this issue. I will try to look at it asap.

For more info about zabbix 5 support see my latest comment in #45

@D3DeFi D3DeFi added bug Something isn't working module The issue or pull request is related to Zabbix module Zabbix 5 support labels May 13, 2020
@toerb
Copy link
Author

toerb commented May 13, 2020

Interestingly since the interfaces are just passed as is we can workaround this bug by adding details to the interface:

  zabbix_host:
    server_url: '{{ monitoring_server }}'
    login_user: '{{ monitoring_user }}'
    login_password: '{{ monitoring_password }}'
    host_name: '{{ ilo_ip }}'
    visible_name: '{{ dns_fqdn }}'
    host_groups: '{{ monitoring_groups | default(["iLO"]) }}'
    link_templates: '{{ monitoring_templates | default(["Template Server HP iLO SNMPv2"]) }}'
    interfaces:
    - type: 2
      main: 1
      useip: 1
      ip: '{{ ilo_ip }}'
      dns: ""
      details:
        version: 2
        community: "{$SNMP_COMMUNITY}"
    status: '{{ monitoring_status | default("enabled") }}'
    state: '{{ monitoring_state | default("present") }}'
    validate_certs: no

@D3DeFi
Copy link
Contributor

D3DeFi commented May 13, 2020

Interestingly since the interfaces are just passed as is we can workaround this bug by adding details to the interface:

  zabbix_host:
    server_url: '{{ monitoring_server }}'
    login_user: '{{ monitoring_user }}'
    login_password: '{{ monitoring_password }}'
    host_name: '{{ ilo_ip }}'
    visible_name: '{{ dns_fqdn }}'
    host_groups: '{{ monitoring_groups | default(["iLO"]) }}'
    link_templates: '{{ monitoring_templates | default(["Template Server HP iLO SNMPv2"]) }}'
    interfaces:
    - type: 2
      main: 1
      useip: 1
      ip: '{{ ilo_ip }}'
      dns: ""
      details:
        version: 2
        community: "{$SNMP_COMMUNITY}"
    status: '{{ monitoring_status | default("enabled") }}'
    state: '{{ monitoring_state | default("present") }}'
    validate_certs: no

Can confirm that this is valid. Additional information in the interfaces dictionary will just miss any error checking and documentation which will come eventually.

@toerb
Copy link
Author

toerb commented May 13, 2020

Adding new hosts with zabbix_host works fine with this environment.
Running the playbook multiple times leads to "changed" messages and not "OK" as it would be expected.

So there seems to be something amiss with the check if the host should be changed.

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

Successfully merging a pull request may close this issue.

3 participants