Skip to content

Add support for hostid parameter to zabbix_valuemap #1451

Open
@osten33

Description

@osten33
SUMMARY

Add support for specifying hostid parameter to zabbix_valuemap to be able to actually map the valuemap to a host or template.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

zabbix_valuemap

ADDITIONAL INFORMATION

Currently, it is not possible to specify the hostid parameter when creating a new valuemap object. If the hostid is not specified the creation of new object will fail. This might actually classify as a bug since the create option actually only works with existing objects and cannot create new.
Creating a new valuemap object with below example and error from API:

  - name: Create valuemaps
    community.zabbix.zabbix_valuemap:
      name: BGP values
   #   hostid: 10115
      mappings:
        - value: 1
          map_to: idle
        - value: 2
          map_to: connect
        - value: 3
          map_to: active
        - value: 4
          map_to: opensent
        - value: 5
          map_to: openconfirm
        - value: 6
          map_to: established
      state: present

TASK [Create valuemaps] ************************************************************************************************************************** fatal: [zabbix]: FAILED! => {"changed": false, "msg": "connection error occurred: REST API returned {'code': -32602, 'message': 'Invalid params.', 'data': 'Invalid parameter \"/1\": the parameter \"hostid\" is missing.'} when sending {\"jsonrpc\": \"2.0\", \"method\": \"valuemap.create\", \"id\": \"3d0e535e-8ca3-40e6-a98d-3c1338b27728\", \"params\": {\"name\": \"BGP values\", \"mappings\": [{\"value\": \"1\", \"newvalue\": \"idle\"}, {\"value\": \"2\", \"newvalue\": \"connect\"}, {\"value\": \"3\", \"newvalue\": \"active\"}, {\"value\": \"4\", \"newvalue\": \"opensent\"}, {\"value\": \"5\", \"newvalue\": \"openconfirm\"}, {\"value\": \"6\", \"newvalue\": \"established\"}]}, \"auth\": \"<omittedtoken>\"}"}

Trying to add hostid in playbook fails as expected:
TASK [Create valuemaps] ************************************************************************************************************************** fatal: [zabbix]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (community.zabbix.zabbix_valuemap) module: hostid. Supported parameters include: http_login_password, http_login_user, mappings, name, state."}

https://www.zabbix.com/documentation/current/en/manual/api/reference/valuemap/create

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestmoduleThe issue or pull request is related to Zabbix module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions