MySQL Chef: NoMethodError: undefined method `set' for #<Chef::Node::Attribute
MySQL Chef: NoMethodError: undefined method `set' for #<Chef::Node::Attribute
我正在尝试使用超市的 MySQL 食谱,但有一些例外情况
我的配置非常基础:
食谱:
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'
我将 Kitchen 与 vagrant 和 centos 6 一起用作平台,但出现此异常:
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>
我也尝试使用更新版本的食谱,但出现了同样的错误
这看起来像是一个 chef-client 问题。我认为您使用的是 14 岁以上的厨师。
这提出了几个问题:
- 您的项目中使用的 chef-client 版本是什么?
- 如果是 Chef 14+,尝试使用最新的超市食谱
- 否则,请按照以下说明进行操作。
在您的 kitchen.yml
中,尝试降级 provisioner
部分下的 chef-client
。请参考以下代码片段:
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"
然后 运行 你的 kitchen destroy
和 kitchen converge
.
发现,好像是chef-client和mysqlcookbook
的兼容性问题
通过在 Berksfile 中指定
cookbook 'mysql', '~> 7.0'
并且在kitchen.yaml
product_name: chef
product_version: 14.12.9
我正在尝试使用超市的 MySQL 食谱,但有一些例外情况
我的配置非常基础:
食谱:
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'
我将 Kitchen 与 vagrant 和 centos 6 一起用作平台,但出现此异常:
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>
我也尝试使用更新版本的食谱,但出现了同样的错误
这看起来像是一个 chef-client 问题。我认为您使用的是 14 岁以上的厨师。
这提出了几个问题:
- 您的项目中使用的 chef-client 版本是什么?
- 如果是 Chef 14+,尝试使用最新的超市食谱
- 否则,请按照以下说明进行操作。
在您的 kitchen.yml
中,尝试降级 provisioner
部分下的 chef-client
。请参考以下代码片段:
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"
然后 运行 你的 kitchen destroy
和 kitchen converge
.
发现,好像是chef-client和mysqlcookbook
的兼容性问题通过在 Berksfile 中指定
cookbook 'mysql', '~> 7.0'
并且在kitchen.yaml
product_name: chef
product_version: 14.12.9