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

Property method of resource zabbix_api_call overwrites an existing method #225

Open
athreyavc1 opened this issue Aug 8, 2017 · 3 comments

Comments

@athreyavc1
Copy link

Hi
chef-client -v
Chef: 13.2.20

Chef Server version is 12.15.6.

Recipe Compile Error in /var/chef/cache/cookbooks/zabbix/resources/api_call.rb
================================================================================

ArgumentError
-------------
Property `method` of resource `zabbix_api_call` overwrites an existing method.

Cookbook Trace:
---------------
  /var/chef/cache/cookbooks/zabbix/resources/api_call.rb:5:in `class_from_file'

Relevant File Content:
----------------------
/var/chef/cache/cookbooks/zabbix/resources/api_call.rb:

  1:  actions :call
  2:  default_action :call
  3:
  4:  attribute :server_connection, :kind_of => Hash, :required => true
  5>> attribute :method, :kind_of => [String, Symbol], :required => true
  6:  attribute :parameters, :kind_of => Hash, :required => true
  7:

System Info:
------------
chef_version=13.2.20
platform=centos
platform_version=7.3.1611
ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
program_name=chef-client worker: ppid=61391;start=16:56:34;
executable=/opt/chef/bin/chef-client
@athreyavc1
Copy link
Author

Checked with previous versions of chef client 13.x same error

@askz
Copy link

askz commented Dec 6, 2017

Same here. Did you managed to resolve the issue?

@athreyavc1
Copy link
Author

I made the cookbook working with CentOS 7, it is certainly not a good fix, just that it is working. I am just using this cookbook deploy clients.

changed resource api_call.rb in providers to

action :call do
  Chef::Zabbix.with_connection(new_resource.server_connection) do |connection|
    connection.query(
      :api_method => new_resource.method,
      :params => new_resource.parameters
    )
  end
  new_resource.updated_by_last_action(true)
end

def load_current_resource
  run_context.include_recipe 'zabbix::_providers_common'
  require 'zabbixapi'
end

def validate_parameters(parameters)
  Chef::Log.error("#{parameter} isn't an Hash") unless parameters.is_a?(Hash)
end

Changed resources/api_call.rb to

actions :call
default_action :call

attribute :server_connection, :kind_of => Hash, :required => true
attribute :api_method, :kind_of => [String, Symbol], :required => true
attribute :parameters, :kind_of => Hash, :required => true

Also in templates and many places attributes are called like,
node.zabbix.attribute_value
This resulted in failure for me on chef client 13.x

changed this to
node['zabbix']['attribute_value']

Now the chef converge is working for me.

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

2 participants