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
Found, it seems to be a compatibility issue between chef-client and mysql cookbook
By specifying in the Berksfile
And in kitchen.yaml
This looks like a chef-client issue. I think you are using chef 14+.
That raises a few questions :
In your
kitchen.yml
, try downgrading thechef-client
under theprovisioner
section. Refer the below snippet :Then run your
kitchen destroy
andkitchen converge
.