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

failure if zabbix hostgroup does not exist #41

Closed
genebean opened this issue Jan 15, 2015 · 3 comments
Closed

failure if zabbix hostgroup does not exist #41

genebean opened this issue Jan 15, 2015 · 3 comments
Labels
bug Something isn't working

Comments

@genebean
Copy link

If a node specifies a hostgroup that does not exist the following failure occurs.

Error: Could not set 'present' on ensure: Server answer API error:
 {
  "code": -32500,
  "message": "Application error.",
  "data": "No permissions to referred object or it does not exist!"
}
 on request:
 {
  "method": "host.create",
  "params": [
    {
      "host": "cent7test.example.edu",
      "interfaces": [
        {
          "type": 1,
          "main": 1,
          "ip": "",
          "dns": "cent7test.example.edu",
          "port": "10050",
          "useip": 0
        }
      ],
      "status": 0,
      "available": 1,
      "groups": [
        {
          "groupid": null
        }
      ],
      "proxy_hostid": null,
      "templates": [
        10001,
        10102
      ]
    }
  ],
  "id": 80395,
  "jsonrpc": "2.0",
  "auth": "ae774e8c6af9b0790929ab1019109332"
} at 37:/etc/puppet/environments/feature_zabbix_agent/modules/zabbix/manifests/resources/agent.pp
Error: Could not set 'present' on ensure: Server answer API error:
 {
  "code": -32500,
  "message": "Application error.",
  "data": "No permissions to referred object or it does not exist!"
}
 on request:
 {
  "method": "host.create",
  "params": [
    {
      "host": "cent7test.example.edu",
      "interfaces": [
        {
          "type": 1,
          "main": 1,
          "ip": "",
          "dns": "cent7test.example.edu",
          "port": "10050",
          "useip": 0
        }
      ],
      "status": 0,
      "available": 1,
      "groups": [
        {
          "groupid": null
        }
      ],
      "proxy_hostid": null,
      "templates": [
        10001,
        10102
      ]
    }
  ],
  "id": 80395,
  "jsonrpc": "2.0",
  "auth": "ae774e8c6af9b0790929ab1019109332"
} at 37:/etc/puppet/environments/feature_zabbix_agent/modules/zabbix/manifests/resources/agent.pp
Wrapped exception:
Server answer API error:
 {
  "code": -32500,
  "message": "Application error.",
  "data": "No permissions to referred object or it does not exist!"
}
 on request:
 {
  "method": "host.create",
  "params": [
    {
      "host": "cent7test.example.edu",
      "interfaces": [
        {
          "type": 1,
          "main": 1,
          "ip": "",
          "dns": "cent7test.example.edu",
          "port": "10050",
          "useip": 0
        }
      ],
      "status": 0,
      "available": 1,
      "groups": [
        {
          "groupid": null
        }
      ],
      "proxy_hostid": null,
      "templates": [
        10001,
        10102
      ]
    }
  ],
  "id": 80395,
  "jsonrpc": "2.0",
  "auth": "ae774e8c6af9b0790929ab1019109332"
}
Error: /Stage[main]/Zabbix::Resources::Agent/Zabbix_host[cent7test.example.edu]/ensure: change from absent to present failed: Could not set 'present' on ensure: Server answer API error:
 {
  "code": -32500,
  "message": "Application error.",
  "data": "No permissions to referred object or it does not exist!"
}
 on request:
 {
  "method": "host.create",
  "params": [
    {
      "host": "cent7test.example.edu",
      "interfaces": [
        {
          "type": 1,
          "main": 1,
          "ip": "",
          "dns": "cent7test.example.edu",
          "port": "10050",
          "useip": 0
        }
      ],
      "status": 0,
      "available": 1,
      "groups": [
        {
          "groupid": null
        }
      ],
      "proxy_hostid": null,
      "templates": [
        10001,
        10102
      ]
    }
  ],
  "id": 80395,
  "jsonrpc": "2.0",
  "auth": "ae774e8c6af9b0790929ab1019109332"
} at 37:/etc/puppet/environments/feature_zabbix_agent/modules/zabbix/manifests/resources/agent.pp
@genebean
Copy link
Author

I do now see that you have in the docs that this should already exist... if you don't want to create the host group then it would be great if the puppet run stopped with a fail message that said the host group doesn't exist rather than the run continuing and all this be spewed by the api gem. Of course, this is just my two cents...

dj-wasabi pushed a commit that referenced this issue Jan 17, 2015
…ith fail if incorrect hostgroup is given.
@dj-wasabi
Copy link
Contributor

I just updated the provider, I've added the following:

    # First check if we have an correct hostgroup and if not, we raise an error.
    search_hostgroup = zbx.hostgroups.get_id(:name => hostgroup)
    if search_hostgroup.nil?
        raise Puppet::Error, "The hostgroup (" + hostgroup + ") does not exist in zabbix. Please use the correct one."
    end

You'll get this error instead of the one mentioned in this issue.

@dj-wasabi dj-wasabi added the bug Something isn't working label Jan 17, 2015
@dj-wasabi
Copy link
Contributor

I've added new release to the forge: 1.1.0.
If you have any questions or problems with this fix, please reopen this issue or create a new one please.

Kind regards,
Werner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants