基本上,我想创建一本安装 MySQL 5.7 的食谱,所以我想利用超市里的 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)
答案1
我 99% 确定您在其他地方交叉发布了此问题,我也在那里回答了,但以防万一:运行这样的单个配方不会处理依赖项。您需要使用 chef-solo 的正常模式(或 chef-client 本地模式,但可能是 solo)。不幸的是,您在这里没有提供足够的信息来了解它会是什么样子。基于 Solo 的工作流程总是更复杂,因为您偏离了常规路径。我们建议您尽可能坚持标准工作流程,直到您对 Chef 足够熟悉以开辟自己的道路。