voxpupuli / puppet-zabbix

Puppet module for creating and maintaining zabbix components with puppet.
https://forge.puppet.com/puppet/zabbix
Apache License 2.0
80 stars 228 forks source link

update host via zabbix api #270

Open borei74 opened 8 years ago

borei74 commented 8 years ago

Hi, First of all thank you for such great module, it's one of the key-part in my infrastructure and saved me tons of time to manage zabbix on all hosts. There are one thing (probably bug im hitting) - update existing host in zabbix. As for example i was changing set of templates assigned to the host. Im working with exported resources. Once templates set was updated and pushed to puppetdb first run of puppet on the zabbix web server generate the following output:

Error: Could not set 'present' on ensure: Server answer API error
 {
  "code": -32602,
  "message": "Invalid params.",
  "data": "Interface is linked to item \"Host name of zabbix_agentd running\" on \"web-be00.se-core.domain.com\"."
}
 on request:
 {
  "method": "host.update",
  "params": [
    {
      "host": "web-be00.se-core.domain.com",
      "interfaces": [
        {
          "type": 1,
          "main": 1,
          "ip": "10.200.128.176",
          "dns": "web-be00.se-core.domain.com",
          "port": "10050",
          "useip": 1
        }
      ],
      "templates": [
        10001,
        10102,
        10094,
        10095,
        10126
      ],
      "groups": [
        {
          "groupid": 2
        }
      ],
      "hostid": 10259
    }
  ],
  "id": 28136,
  "jsonrpc": "2.0",
  "auth": "03ebc695ca67c40dc910f166203c6a58"
} at 27:/etc/puppetlabs/code/modules/zabbix/manifests/resources/agent.pp
Error: Could not set 'present' on ensure: Server answer API error
 {
  "code": -32602,
  "message": "Invalid params.",
  "data": "Interface is linked to item \"Host name of zabbix_agentd running\" on \"web-be00.se-core.domain.com\"."
}
 on request:
 {
  "method": "host.update",
  "params": [
    {
      "host": "web-be00.se-core.domain.com",
      "interfaces": [
        {
          "type": 1,
          "main": 1,
          "ip": "10.200.128.176",
          "dns": "web-be00.se-core.domain.com",
          "port": "10050",
          "useip": 1
        }
      ],
      "templates": [
        10001,
        10102,
        10094,
        10095,
        10126
      ],
      "groups": [
        {
          "groupid": 2
        }
      ],
      "hostid": 10259
    }
  ],
  "id": 28136,
  "jsonrpc": "2.0",
  "auth": "03ebc695ca67c40dc910f166203c6a58"
} at 27:/etc/puppetlabs/code/modules/zabbix/manifests/resources/agent.pp
Wrapped exception:
Server answer API error
 {
  "code": -32602,
  "message": "Invalid params.",
  "data": "Interface is linked to item \"Host name of zabbix_agentd running\" on \"web-be00.se-core.domain.com\"."
}
 on request:
 {
  "method": "host.update",
  "params": [
    {
      "host": "web-be00.se-core.domain.com",
      "interfaces": [
        {
          "type": 1,
          "main": 1,
          "ip": "10.200.128.176",
          "dns": "web-be00.se-core.domain.com",
          "port": "10050",
          "useip": 1
        }
      ],
      "templates": [
        10001,
        10102,
        10094,
        10095,
        10126
      ],
      "groups": [
        {
          "groupid": 2
        }
      ],
      "hostid": 10259
    }
  ],
  "id": 28136,
  "jsonrpc": "2.0",
  "auth": "03ebc695ca67c40dc910f166203c6a58"
}
Error: /Stage[main]/Zabbix::Resources::Agent/Zabbix_host[web-be00.se-core.domain.com]/ensure: change from absent to present failed: Could not set 'present' on ensure: Server answer API error
 {
  "code": -32602,
  "message": "Invalid params.",
  "data": "Interface is linked to item \"Host name of zabbix_agentd running\" on \"web-be00.se-core.domain.com\"."
}
 on request:
 {
  "method": "host.update",
  "params": [
    {
      "host": "web-be00.se-core.domain.com",
      "interfaces": [
        {
          "type": 1,
          "main": 1,
          "ip": "10.200.128.176",
          "dns": "web-be00.se-core.domain.com",
          "port": "10050",
          "useip": 1
        }
      ],
      "templates": [
        10001,
        10102,
        10094,
        10095,
        10126
      ],
      "groups": [
        {
          "groupid": 2
        }
      ],
      "hostid": 10259
    }
  ],
  "id": 28136,
  "jsonrpc": "2.0",
  "auth": "03ebc695ca67c40dc910f166203c6a58"
} at 27:/etc/puppetlabs/code/modules/zabbix/manifests/resources/agent.pp

after that i removed existing in zabbix host web-be00.se-core.domain.com, and run puppet agent again:

Error: Could not set 'present' on ensure: host not supplied in call to get_id at 27:/etc/puppetlabs/code/modules/zabbix/manifests/resources/agent.pp
Error: Could not set 'present' on ensure: host not supplied in call to get_id at 27:/etc/puppetlabs/code/modules/zabbix/manifests/resources/agent.pp
Wrapped exception:
host not supplied in call to get_id
Error: /Stage[main]/Zabbix::Resources::Agent/Zabbix_host[web-be00.se-core.domain.com]/ensure: change from absent to present failed: Could not set 'present' on ensure: host not supplied in call to get_id at 27:/etc/puppetlabs/code/modules/zabbix/manifests/resources/agent.pp

but after that run host was added into zabbix

third run produced no errors.

Main problem as i see - host update functionality doesn't work as expected.

Please let me know if i need to provide more technical details or run any types of tests.

baurmatt commented 5 years ago

@borei74 Is this still a problem with the current version of this module?

superzc-github commented 3 years ago

any explain or updates on this issue please? im seeing this too.