skip to Main Content

I am trying to use the MySQL cookbook from the supermarket but having some exceptions

My config is very basic:

Recipe:

mysql_service 'foo' do
  port '3306'
  version '5.5'
  initial_root_password 'changeme'
  action [:create, :start]
end

Metadata.rb

depends 'mysql', '~> 6.0'

Berksfile

cookbook 'mysql', '~> 6.0'

I using Kitchen with vagrant and centos 6 as a platform but getting this exception:

         Recipe: test-mysql::default
         * mysql_service[foo] action create

           ================================================================================
           Error executing action `create` on resource 'mysql_service[foo]'
           ================================================================================

           NoMethodError
           -------------
           undefined method `set' for #<Chef::Node::Attribute:0x00000000037bc818>

           Cookbook Trace: (most recent call first)
           ----------------------------------------
           /tmp/kitchen/cache/cookbooks/mysql/libraries/helpers.rb:265:in `pkginfo'
           /tmp/kitchen/cache/cookbooks/mysql/libraries/helpers.rb:388:in `package_name_for'
           /tmp/kitchen/cache/cookbooks/mysql/libraries/helpers.rb:431:in `server_package'
           /tmp/kitchen/cache/cookbooks/mysql/libraries/helpers.rb:442:in `server_package_name'
           /tmp/kitchen/cache/cookbooks/mysql/libraries/provider_mysql_service_base.rb:31:in `block in <class:MysqlServiceBase>'

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/test-mysql/recipes/default.rb

             1: mysql_service 'foo' do
             2:   port '3306'
             3:   version '5.5'
             4:   initial_root_password 'changeme'
             5:   action [:create, :start]
             6: end

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/test-mysql/recipes/default.rb:1:in `from_file'

           mysql_service("foo") do
             action [:create, :start]
             default_guard_interpreter :default
             declared_type :mysql_service
             cookbook_name "test-mysql"
             recipe_name "default"
             port "3306"
             version "5.5"
             initial_root_password "changeme"
           end

           System Info:
           ------------
           chef_version=16.4.41
           platform=centos
           platform_version=6.10
           ruby=ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
           program_name=/opt/chef/bin/chef-client
           executable=/opt/chef/bin/chef-client


       Running handlers:
       [2020-08-28T04:30:27+00:00] ERROR: Running exception handlers
       Running handlers complete
       [2020-08-28T04:30:27+00:00] ERROR: Exception handlers complete
       Chef Infra Client failed. 0 resources updated in 01 seconds
       [2020-08-28T04:30:27+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       [2020-08-28T04:30:27+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
       [2020-08-28T04:30:27+00:00] FATAL: NoMethodError: mysql_service[foo] (test-mysql::default line 1) had an error: NoMethodError: undefined method `set' for #<Chef::Node::Attribute:0x00000000037bc818>

I also tried with a more recent version of the cookbook but getting the same error

2

Answers


  1. Chosen as BEST ANSWER

    Found, it seems to be a compatibility issue between chef-client and mysql cookbook

    By specifying in the Berksfile

    cookbook 'mysql', '~> 7.0' 
    

    And in kitchen.yaml

    product_name: chef
    product_version: 14.12.9
    

  2. This looks like a chef-client issue. I think you are using chef 14+.

    That raises a few questions :

    • What is the chef-client version used in your projects ?
    • if its Chef 14+ , try using the latest supermarket cookbook
    • Else, follow the instructions below.

    In your kitchen.yml, try downgrading the chef-client under the provisioner section. Refer the below snippet :

    provisioner:
      name: chef_zero
      # You may wish to disable always updating cookbooks in CI or other testing environments.
      # For example:
      #   always_update_cookbooks: <%= !ENV['CI'] %>
      always_update_cookbooks: true
      product_name: chef
      product_version: 12.21
      chef_omnibus_url: "file:///opt/softwares/chef-12.21.26-1.el6.x86_64.rpm"
    

    Then run your kitchen destroy and kitchen converge.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search