sinfomicien / mysql2_chef_gem

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting "wrong number of arguments (2 for 0)" when installing.

hemikak opened this issue · comments

Hi all,
I am trying to create a mysql database in my recipe. But when I tried to create the database, I got the following error.

"cannot load such file -- mysql2"

I think I found the fix for it at http://lists.opscode.com/sympa/arc/chef/2015-02/msg00244.html.

But when I added the following code to my recipe and error pops out.

mysql2_chef_gem 'default' do
action :install
end

Error executing action `install` on resource 'mysql2_chef_gem[default]'
================================================================================

ArgumentError
-------------
wrong number of arguments (2 for 0)

Resource Declaration:
---------------------
# In /var/root/chef-mb/cookbooks/wso2_mb_mysql_database/recipes/default.rb

 14: mysql2_chef_gem 'default' do
 15:   action :install
 16: end
 17:

Compiled Resource:
------------------
# Declared in /var/root/chef-mb/cookbooks/wso2_mb_mysql_database/recipes/default.rb:14:in `from_file'

mysql2_chef_gem("default") do
  action [:install]
  retries 0
  retry_delay 2
  default_guard_interpreter :default
  declared_type :mysql2_chef_gem
  cookbook_name :wso2_mb_mysql_database
  recipe_name "default"
end

I also added "depends 'mysql2_chef_gem', '~> 1.0.1'" in my metadeta file. I am using MAC OS X Yosemite and my ruby version is "ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-darwin14.0]"

Any idea how I can get passed this ?

I ran into same error, can someone stand out for help? an y help will be appreciated.
ArgumentError
-------------
wrong number of arguments (2 for 0)

Resource Declaration:
---------------------
# In /root/.chef/local-mode-cache/cache/cookbooks/ops-db-install/recipes/default.rb

 43: mysql2_chef_gem 'default' do
 44:  gem_version '0.3.0'
 45:  action :install
 46: end
 47: 

can anyone share the resolution? I'm also getting the same error

@SenthilnathanVedi: do you still have the full output/stack trace for the failure available? Would you mind pasting it here or in a gist?

Hi, here is the stack trace

Generated at 2015-08-19 14:06:04 -0400
ArgumentError: mysql2_chef_gem[default](awesome_customers::database line 8) had an error: ArgumentError: wrong number of arguments (2 for 0)
/opt/chef/embedded/apps/chef/lib/chef/resource.rb:1205:in initialize' /opt/chef/embedded/apps/chef/lib/chef/resource.rb:1205:innew'
/opt/chef/embedded/apps/chef/lib/chef/resource.rb:1205:in provider_for_action' /opt/chef/embedded/apps/chef/lib/chef/resource.rb:584:inrun_action'
/opt/chef/embedded/apps/chef/lib/chef/runner.rb:49:in run_action' /opt/chef/embedded/apps/chef/lib/chef/runner.rb:81:inblock (2 levels) in converge'
/opt/chef/embedded/apps/chef/lib/chef/runner.rb:81:in each' /opt/chef/embedded/apps/chef/lib/chef/runner.rb:81:inblock in converge'
/opt/chef/embedded/apps/chef/lib/chef/resource_collection/resource_list.rb:83:in block in execute_each_resource' /opt/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:incall'
/opt/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in call_iterator_block' /opt/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:85:instep'
/opt/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:104:in iterate' /opt/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:55:ineach_with_index'
/opt/chef/embedded/apps/chef/lib/chef/resource_collection/resource_list.rb:81:in execute_each_resource' /opt/chef/embedded/apps/chef/lib/chef/runner.rb:80:inconverge'
/opt/chef/embedded/apps/chef/lib/chef/client.rb:654:in block in converge' /opt/chef/embedded/apps/chef/lib/chef/client.rb:649:incatch'
/opt/chef/embedded/apps/chef/lib/chef/client.rb:649:in converge' /opt/chef/embedded/apps/chef/lib/chef/client.rb:688:inconverge_and_save'
/opt/chef/embedded/apps/chef/lib/chef/client.rb:269:in run' /opt/chef/embedded/apps/chef/lib/chef/application.rb:270:inblock in fork_chef_client'
/opt/chef/embedded/apps/chef/lib/chef/application.rb:258:in fork' /opt/chef/embedded/apps/chef/lib/chef/application.rb:258:infork_chef_client'
/opt/chef/embedded/apps/chef/lib/chef/application.rb:224:in block in run_chef_client' /opt/chef/embedded/apps/chef/lib/chef/local_mode.rb:39:inwith_server_connectivity'
/opt/chef/embedded/apps/chef/lib/chef/application.rb:212:in run_chef_client' /opt/chef/embedded/apps/chef/lib/chef/application/client.rb:402:inblock in interval_run_chef_client'
/opt/chef/embedded/apps/chef/lib/chef/application/client.rb:392:in loop' /opt/chef/embedded/apps/chef/lib/chef/application/client.rb:392:ininterval_run_chef_client'
/opt/chef/embedded/apps/chef/lib/chef/application/client.rb:382:in run_application' /opt/chef/embedded/apps/chef/lib/chef/application.rb:60:inrun'
/opt/chef/embedded/apps/chef/bin/chef-client:26:in <top (required)>' /usr/bin/chef-client:55:inload'
/usr/bin/chef-client:55:in `

'

Step#5 at https://learn.chef.io/manage-a-web-app/rhel/apply-and-verify-your-database-configuration/

Complete console output while running knife ssh command :

Starting Chef Client, version 12.4.1
resolving cookbooks for run list: ["awesome_customers"]
Synchronizing Cookbooks:

  • httpd

  • selinux

  • iptables

  • awesome_customers

  • mysql2_chef_gem

  • build-essential

  • mysql

  • yum

  • yum-mysql-community

  • rbac

  • smf

  • mariadb

  • yum-epel

  • apt

  • database

  • chef-sugar

  • postgresql

  • openssl
    Compiling Cookbooks...
    [2015-08-19T13:26:29-04:00] WARN: You declared a new resource Chef::Provider::HttpdServiceRhelSysvinit for resource httpd_service, but it comes alphabetically after Chef::Provider::HttpdServiceRhelSystemd and has the same filters ({:platform_family=>["rhel", "fedora", "suse"]}), so it will not be used. Use override: true if you want to use it for httpd_service.
    [2015-08-19T13:26:29-04:00] WARN: You are overriding httpd_service on {:platform_family=>["rhel", "fedora", "suse"]} with Chef::Provider::HttpdServiceRhelSystemd: used to be Chef::Provider::HttpdServiceRhelSysvinit. Use override: true if this is what you intended.
    [2015-08-19T13:26:29-04:00] WARN: You declared a new resource Chef::Provider::HttpdServiceRhelSysvinit for resource httpd_service, but it comes alphabetically after Chef::Provider::HttpdServiceRhelSystemd and has the same filters ({:platform_family=>["rhel", "fedora", "suse"]}), so it will not be used. Use override: true if you want to use it for httpd_service.
    [2015-08-19T13:26:29-04:00] WARN: You declared a new resource Chef::Provider::HttpdServiceRhelSysvinit for resource httpd_service, but it comes alphabetically after Chef::Provider::HttpdServiceRhelSystemd and has the same filters ({:platform_family=>["rhel", "fedora", "suse"]}), so it will not be used. Use override: true if you want to use it for httpd_service.
    Converging 22 resources
    Recipe: selinux::_common

    • yum_package[libselinux-utils] action install (up to date)
  • directory[/etc/selinux] action create (up to date)
    Recipe: selinux::permissive

    • selinux_state[SELinux Permissive] action permissive (up to date)
      Recipe: awesome_customers::user
    • group[web_admin] action create (up to date)
  • user[web_admin] action create (up to date)
    Recipe: awesome_customers::webserver

    • httpd_service[customers] action create
      • yum_package[customers :create httpd] action install (up to date)
      • service[customers :create httpd] action stop (up to date)
      • service[customers :create httpd] action disable (up to date)
      • yum_package[customers :create net-tools] action install (up to date)
      • httpd_module[customers :create log_config] action create
        • yum_package[customers :create log_config :create httpd] action install (up to date)
        • directory[customers :create log_config :create /etc/httpd-customers/conf.d] action create (up to date)
        • template[customers :create log_config :create /etc/httpd-customers/conf.d/log_config.load] action create (up to date)
          (up to date)
      • httpd_module[customers :create logio] action create
        • yum_package[customers :create logio :create httpd] action install (up to date)
        • directory[customers :create logio :create /etc/httpd-customers/conf.d] action create (up to date)
        • template[customers :create logio :create /etc/httpd-customers/conf.d/logio.load] action create (up to date)
          (up to date)
      • link[customers :create /usr/sbin/httpd-customers] action create (up to date)
      • link[customers :create /usr/sbin/httpd-customers.worker] action create (up to date)
      • link[customers :create /usr/sbin/httpd-customers.event] action create (up to date)
      • httpd_config[customers :create mpm_prefork] action create
        • directory[customers :create mpm_prefork :create /etc/httpd-customers/conf.d] action create (up to date)
        • template[customers :create mpm_prefork :create /etc/httpd-customers/conf.d/mpm_prefork.conf] action create (up to date)
          (up to date)
      • directory[customers :create /etc/httpd-customers] action create (up to date)
      • directory[customers :create /etc/httpd-customers/conf] action create (up to date)
      • directory[customers :create /etc/httpd-customers/conf.d] action create (up to date)
      • directory[customers :create /usr/lib64/httpd/modules] action create (up to date)
      • directory[customers :create /var/log/httpd-customers] action create (up to date)
      • link[customers :create /etc/httpd-customers/logs] action create (up to date)
      • link[customers :create /etc/httpd-customers/modules] action create (up to date)
      • directory[customers :create /var/run/httpd-customers] action create (up to date)
      • link[customers :create /etc/httpd-customers/run] action create (up to date)
      • template[customers :create /etc/httpd-customers/conf/mime.types] action create (up to date)
      • template[customers :create /etc/httpd-customers/conf/httpd.conf] action create (up to date)
      • httpd_module[customers :create alias] action create
        • yum_package[customers :create alias :create httpd] action install (up to date)
        • directory[customers :create alias :create /etc/httpd-customers/conf.d] action create (up to date)
        • template[customers :create alias :create /etc/httpd-customers/conf.d/alias.load] action create (up to date)
          (up to date)
      • httpd_module[customers :create autoindex] action create
        • yum_package[customers :create autoindex :create httpd] action install (up to date)
        • directory[customers :create autoindex :create /etc/httpd-customers/conf.d] action create (up to date)
        • template[customers :create autoindex :create /etc/httpd-customers/conf.d/autoindex.load] action create (up to date)
          (up to date)
      • httpd_module[customers :create dir] action create
        • yum_package[customers :create dir :create httpd] action install (up to date)
        • directory[customers :create dir :create /etc/httpd-customers/conf.d] action create (up to date)
        • template[customers :create dir :create /etc/httpd-customers/conf.d/dir.load] action create (up to date)
          (up to date)
      • httpd_module[customers :create env] action create
        • yum_package[customers :create env :create httpd] action install (up to date)
        • directory[customers :create env :create /etc/httpd-customers/conf.d] action create (up to date)
        • template[customers :create env :create /etc/httpd-customers/conf.d/env.load] action create (up to date)
          (up to date)
      • httpd_module[customers :create mime] action create
        • yum_package[customers :create mime :create httpd] action install (up to date)
        • directory[customers :create mime :create /etc/httpd-customers/conf.d] action create (up to date)
        • template[customers :create mime :create /etc/httpd-customers/conf.d/mime.load] action create (up to date)
          (up to date)
      • httpd_module[customers :create negotiation] action create
        • yum_package[customers :create negotiation :create httpd] action install (up to date)
        • directory[customers :create negotiation :create /etc/httpd-customers/conf.d] action create (up to date)
        • template[customers :create negotiation :create /etc/httpd-customers/conf.d/negotiation.load] action create (up to date)
          (up to date)
      • httpd_module[customers :create setenvif] action create
        • yum_package[customers :create setenvif :create httpd] action install (up to date)
        • directory[customers :create setenvif :create /etc/httpd-customers/conf.d] action create (up to date)
        • template[customers :create setenvif :create /etc/httpd-customers/conf.d/setenvif.load] action create (up to date)
          (up to date)
      • httpd_module[customers :create status] action create
        • yum_package[customers :create status :create httpd] action install (up to date)
        • directory[customers :create status :create /etc/httpd-customers/conf.d] action create (up to date)
        • template[customers :create status :create /etc/httpd-customers/conf.d/status.load] action create (up to date)
          (up to date)
      • httpd_module[customers :create auth_basic] action create
        • yum_package[customers :create auth_basic :create httpd] action install (up to date)
        • directory[customers :create auth_basic :create /etc/httpd-customers/conf.d] action create (up to date)
        • template[customers :create auth_basic :create /etc/httpd-customers/conf.d/auth_basic.load] action create (up to date)
          (up to date)
      • httpd_module[customers :create deflate] action create
        • yum_package[customers :create deflate :create httpd] action install (up to date)
        • directory[customers :create deflate :create /etc/httpd-customers/conf.d] action create (up to date)
        • template[customers :create deflate :create /etc/httpd-customers/conf.d/deflate.load] action create (up to date)
          (up to date)
      • httpd_module[customers :create authz_default] action create
        • yum_package[customers :create authz_default :create httpd] action install (up to date)
        • directory[customers :create authz_default :create /etc/httpd-customers/conf.d] action create (up to date)
        • template[customers :create authz_default :create /etc/httpd-customers/conf.d/authz_default.load] action create (up to date)
          (up to date)
      • httpd_module[customers :create authz_user] action create
        • yum_package[customers :create authz_user :create httpd] action install (up to date)
        • directory[customers :create authz_user :create /etc/httpd-customers/conf.d] action create (up to date)
        • template[customers :create authz_user :create /etc/httpd-customers/conf.d/authz_user.load] action create (up to date)
          (up to date)
      • httpd_module[customers :create authz_groupfile] action create
        • yum_package[customers :create authz_groupfile :create httpd] action install (up to date)
        • directory[customers :create authz_groupfile :create /etc/httpd-customers/conf.d] action create (up to date)
        • template[customers :create authz_groupfile :create /etc/httpd-customers/conf.d/authz_groupfile.load] action create (up to date)
          (up to date)
      • httpd_module[customers :create authn_file] action create
        • yum_package[customers :create authn_file :create httpd] action install (up to date)
        • directory[customers :create authn_file :create /etc/httpd-customers/conf.d] action create (up to date)
        • template[customers :create authn_file :create /etc/httpd-customers/conf.d/authn_file.load] action create (up to date)
          (up to date)
      • httpd_module[customers :create authz_host] action create
        • yum_package[customers :create authz_host :create httpd] action install (up to date)
        • directory[customers :create authz_host :create /etc/httpd-customers/conf.d] action create (up to date)
        • template[customers :create authz_host :create /etc/httpd-customers/conf.d/authz_host.load] action create (up to date)
          (up to date)
      • httpd_module[customers :create reqtimeout] action create
        • yum_package[customers :create reqtimeout :create httpd] action install (up to date)
        • directory[customers :create reqtimeout :create /etc/httpd-customers/conf.d] action create (up to date)
        • template[customers :create reqtimeout :create /etc/httpd-customers/conf.d/reqtimeout.load] action create (up to date)
          (up to date)
          (up to date)
  • httpd_service[customers] action start

    • template[customers :create /etc/init.d/httpd-customers] action create (up to date)
    • template[customers :create /etc/sysconfig/httpd-customers] action create (up to date)
    • service[customers :create httpd-customers] action start (up to date)
    • service[customers :create httpd-customers] action enable (up to date)
      (up to date)
  • httpd_config[customers] action create

    • directory[customers :create /etc/httpd-customers/conf.d] action create (up to date)
    • template[customers :create /etc/httpd-customers/conf.d/customers.conf] action create (up to date)
      (up to date)
  • directory[/var/www/customers/public_html] action create (up to date)

  • file[/var/www/customers/public_html/index.php] action create (up to date)
    Recipe: iptables::default

    • yum_package[iptables] action install (up to date)
  • execute[rebuild-iptables] action nothing (skipped due to action :nothing)

  • directory[/etc/iptables.d] action create (up to date)

  • template[/usr/sbin/rebuild-iptables] action create (up to date)
    Recipe: awesome_customers::firewall

    • iptables_rule[firewall_http] action enable
      • execute[rebuild-iptables] action nothing (skipped due to action :nothing)
      • template[/etc/iptables.d/firewall_http] action create (up to date)
        (up to date)
  • iptables_rule[firewall_sshd] action enable

    • execute[rebuild-iptables] action nothing (skipped due to action :nothing)

    • template[/etc/iptables.d/firewall_sshd] action create (up to date)
      (up to date)
      Recipe: awesome_customers::database

    • mysql2_chef_gem[default] action install[2015-08-19T13:26:37-04:00] WARN: Class Chef::Provider::Mysql2ChefGem does not declare 'resource_name :mysql2_chef_gem'.
      [2015-08-19T13:26:37-04:00] WARN: This will no longer work in Chef 13: you must use 'resource_name' to provide DSL.

      ================================================================================
      Error executing action install on resource 'mysql2_chef_gem[default]'
      ================================================================================

      ArgumentError

      wrong number of arguments (2 for 0)

      Resource Declaration:

      In /var/chef/cache/cookbooks/awesome_customers/recipes/database.rb

      8: mysql2_chef_gem 'default' do
      9: action :install
      10: end
      11:

      Compiled Resource:

      Declared in /var/chef/cache/cookbooks/awesome_customers/recipes/database.rb:8:in `from_file'

      mysql2_chef_gem("default") do
      action [:install]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :mysql2_chef_gem
      cookbook_name "awesome_customers"
      recipe_name "database"
      end

    Running handlers:
    [2015-08-19T13:26:37-04:00] ERROR: Running exception handlers
    Running handlers complete
    [2015-08-19T13:26:37-04:00] ERROR: Exception handlers complete
    Chef Client failed. 0 resources updated in 16.626292917 seconds
    [2015-08-19T13:26:37-04:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
    [2015-08-19T13:26:37-04:00] ERROR: mysql2_chef_gem[default](awesome_customers::database line 8) had an error: ArgumentError: wrong number of arguments (2 for 0)
    rws3511435.us.oracle.com [2015-08-19T13:26:37-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

my database.rb is same as that of tutorial. Anyways the first 15 lines code from my database.rb :

Cookbook Name:: awesome_customers

Recipe:: database

Copyright (c) 2015 The Authors, All Rights Reserved.

Configure the mysql2 Ruby gem.

mysql2_chef_gem 'default' do
action :install
end

Configure the MySQL client.

mysql_client 'default' do
action :create
end

Sorry about the bold texts. Didn't notice how that came from

Hi, any suggestions or pointers to get around this issue?

What platform are you on?

I am also getting the same error while using netdev cookbook:

Converging 3 resources
Recipe: netdev-master_latest::interface_create

  • netdev_interface[ge-1/1/1] action create[2015-08-27T11:17:37+05:30] INFO: Processing netdev_interface[ge-1/1/1] action create (netdev-master_latest::interface_create line 1)

Error executing action create on resource 'netdev_interface[ge-1/1/1]'

ArgumentError

wrong number of arguments(2 for 0)

Resource Declaration:

in /var/chef/cache/cookbooks/netdev-master_latest/recipes/interface_create.rb

1: netdev_interface "ge-1/1/1" do
2: description "access interface"
3: speed "40g"
4: action :create
5: end
6:

Compiled Resource:

Declared in /var/chef/cache/cookbooks/netdev-master_latest/recipes/interface_create.rb:1:in `from_file'

netdev_interface("ge-1/1/1") do
action [:create]
retries 0
retry_delay 2
interface_name "ge-1/1/1"
description "access interface"
enable true
speed "40g"
duplex "auto"
cookbook_name "netdev-master_latest"
recipe_name "interface_create"
end

[2015-08-27T11:17:37+05:30] INFO: Running queued delayed notifications before re-raising exception

Running handlers:
[2015-08-27T11:17:37+05:30] ERROR: Running exception handlers

  • JunosCommitTransactionHandler
    Running handlers complete

[2015-08-27T11:17:37+05:30] ERROR: Exception handlers complete
[2015-08-27T11:17:37+05:30] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 2.877013273 seconds
[2015-08-27T11:17:37+05:30] ERROR: netdev_interface[ge-1/1/1](netdev-master_latest::interface_create line 1) had an error: ArgumentError: wrong number of arguments(2 for 0)
[2015-08-27T11:17:37+05:30] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

It looks like this is an issue with the provider map. I ran into the same issue on 12.4.1 and from what I can tell when Chef attempts to find the provider it falls through to the Name match which is returning Chef::Provider::Mysql2ChefGem instead of Chef::Provider::Mysql2ChefGem::Mysql

A workaround for the caller might be #6:

mysql2_chef_gem 'default' do
  provider Chef::Provider::MysqlChefGem::Mysql
  action :install
end

However, ultimately the resource or provider classes should probably just be renamed so that the resource, when converted to a string, doesn't String match against an abstract base class Chef::Resource::Mysql2ChefGem.

This is pedantic, so I apologize, but for anyone using @martinb3 's fix, which works great btw, the Class name is Mysql2ChefGem, with a '2'.

provider Chef::Provider::Mysql2ChefGem::Mysql

Thanks @martinb3

Also, just a note, while we encountered this in a chef upgrade from 12.4.x to 12.5.1, it should also be noted that we were in the process of upgrading from centos 6.6 to centos 7.1

The resources have been rewritten for the 2.0 release of this cookbook. This is probably resolves at this point. Feel free to open it back up if you're still having the issue