What is causing this error ERROR: undefined method `mysql_service' for #<Chef::Recipe:0x00000003ca0870>?

What is causing this error ERROR: undefined method `mysql_service' for #<Chef::Recipe:0x00000003ca0870>?

基本上我想创建一个安装 MySQL 5.6 的食谱,所以我会利用超市的 mysql。

我首先使用 chef generate cookbook MYSQL 创建了一本新的食谱,然后添加了 depends 'mysql', '~> 8.0' 和 运行 一个 berks install,其中 运行 成功并安装了 mysql 食谱。

这是我的default.rb

mysql_service 'default' do
 version '5.7'
 bind_address '0.0.0.0'
 port '3306'
 data_dir '/data'
 initial_root_password 'vagrant'
 action [:create, :start]
end

我 运行 这个命令到 运行 食谱 - sudo chef-client --local recipes/default.rb 这给了我以下输出

[2017-08-23T18:54:31+00:00] INFO: Started chef-zero at chefzero://localhost:1 with repository at /home/vagrant
One version per cookbook
[2017-08-23T18:54:31+00:00] INFO: Forking chef instance to converge...
Starting Chef Client, version 13.2.20
[2017-08-23T18:54:31+00:00] INFO: *** Chef 13.2.20 ***
[2017-08-23T18:54:31+00:00] INFO: Platform: x86_64-linux
[2017-08-23T18:54:31+00:00] INFO: Chef-client pid: 26421
[2017-08-23T18:54:31+00:00] INFO: The plugin path /etc/chef/ohai/plugins does not exist. Skipping...
[2017-08-23T18:54:33+00:00] INFO: Run List is []
[2017-08-23T18:54:33+00:00] INFO: Run List expands to []
[2017-08-23T18:54:33+00:00] INFO: Starting Chef Run for ardent-admin
[2017-08-23T18:54:33+00:00] INFO: Running start handlers
[2017-08-23T18:54:33+00:00] INFO: Start handlers complete.
resolving cookbooks for run list: []
[2017-08-23T18:54:33+00:00] INFO: Loading cookbooks []
Synchronizing Cookbooks:
Installing Cookbook Gems:
Compiling Cookbooks...

Running handlers:
[2017-08-23T18:54:33+00:00] ERROR: Running exception handlers
Running handlers complete
[2017-08-23T18:54:33+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 02 seconds
[2017-08-23T18:54:33+00:00] FATAL: Stacktrace dumped to 
/home/vagrant/.chef/local-mode-cache/cache/chef-stacktrace.out
[2017-08-23T18:54:33+00:00] FATAL: Please provide the contents of the 
stacktrace.out file if you file a bug report
[2017-08-23T18:54:33+00:00] ERROR: undefined method `mysql_service' for #<Chef::Recipe:0x00000004e58a68>
[2017-08-23T18:54:33+00:00] FATAL: 
Chef::Exceptions::ChildConvergeError: Chef run process exited 
unsuccessfully (exit code 1)



[2017-08-24T13:04:11+00:00] WARN: 
*****************************************
[2017-08-24T13:04:11+00:00] WARN: Did not find config file: 
/etc/chef/solo.rb, using command line options.
[2017-08-24T13:04:11+00:00] WARN: 
*****************************************
/opt/chefdk/embedded/lib/ruby/2.4.0/open-uri.rb:37:in `initialize': 
No such file or directory @ rb_sysopen - recipes[MYSQL::default] 
(Errno::ENOENT)
from /opt/chefdk/embedded/lib/ruby/2.4.0/open-uri.rb:37:in `open'
from /opt/chefdk/embedded/lib/ruby/2.4.0/open-uri.rb:37:in `open'
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.2.20/lib/chef/application/client.rb:532:in `block in fetch_recipe_tarball'
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.2.20/lib/chef/application/client.rb:531:in `open'
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.2.20/lib/chef/application/client.rb:531:in `fetch_recipe_tarball'
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.2.20/lib/chef/application/client.rb:346:in `reconfigure'
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.2.20/lib/chef/application.rb:57:in `run'
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.2.20/lib/chef/application/solo.rb:225:in `run'
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.2.20/bin/chef-solo:25:in `<top (required)>'
from /usr/bin/chef-solo:263:in `load'
from /usr/bin/chef-solo:263:in `<main>'

运行 像这样的单一配方根本不处理依赖关系。除了第一个 Chef 教程之外,一般不推荐用于其他任何内容。你想要像 chef-solo -r 'recipe[mycookbook::default].

这样的东西