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

Resource zabbix_host fails when there's a host with no interface type 1 #660

Open
ludimax opened this issue Feb 27, 2020 · 3 comments
Open

Comments

@ludimax
Copy link

ludimax commented Feb 27, 2020

interface = h['interfaces'].select { |i| i['type'].to_i == 1 && i['main'].to_i == 1 }.first

This fails when there's a host with no interface which has 'type' with value 1.

Error: Could not run: undefined method `[]' for nil:NilClass
/opt/puppetlabs/puppet/cache/lib/puppet/provider/zabbix_host/ruby.rb:19:in `block in instances'
/opt/puppetlabs/puppet/cache/lib/puppet/provider/zabbix_host/ruby.rb:17:in `map'
/opt/puppetlabs/puppet/cache/lib/puppet/provider/zabbix_host/ruby.rb:17:in `instances'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:1199:in `block in instances'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:1198:in `collect'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:1198:in `instances'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/resource/ral.rb:24:in `search'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/indirection.rb:299:in `search'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/resource.rb:228:in `find_or_save_resources'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/resource.rb:142:in `block in main'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/context.rb:62:in `override'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb:274:in `override'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/resource.rb:137:in `main'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:390:in `run_command'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:382:in `block in run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:710:in `exit_on_fail'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:382:in `run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:143:in `run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:77:in `execute'
/opt/puppetlabs/puppet/bin/puppet:5:in `<main>'

Example from Zabbix API:

 {
            "hostid": "10344",
            "host": "<hostname>",
            "proxy_hostid": "10263",
            "groups": [
                {
                    "groupid": "18",
                    "name": "<groupname>"
                }
            ],
            "parentTemplates": [
                {
                    "host": "Template OS Linux SNMPv2",
                    "templateid": "10248"
                }
            ],
            "interfaces": [
                {
                    "interfaceid": "48",
                    "type": "2",
                    "main": "1",
                    "ip": "<ip>",
                    "port": "161",
                    "useip": "1"
                }
            ]
        }
@Fabian1976
Copy link
Contributor

Any progress on this? I ran into the same issue. It is perfectly fine to have hosts with only a SNMP interface (Firewall/Switch).

@aclarkee
Copy link

aclarkee commented Sep 3, 2020

Ran into this today, had to deny the zabbix api user from accessing the affected resources in zabbix. Providing the user has no access to the resources, you wont get the error. Obviously means you can't manage the resources in puppet using this module as well, until this is fixed.

@igalic
Copy link
Contributor

igalic commented Sep 4, 2020

@aclarkee thanks for tracing this down
hopefully somebody can make sense of this and patch it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants