我正在尝试使用 Chef 安装 Redis。我想,这很容易,因为我只想拥有默认配置。
所以,我添加到 Berksfile:
站点:操作码 食谱“适合” 食谱“节点” 食谱'rvm',:git =>“https://github.com/fnichol/chef-rvm” 食谱“单元” 食谱'redis'
然后,我运行: vagrant provision
但我明白了:
2013-12-11T21:18:23+00:00] 调试:chef_gem [rvm] 已安装 - 无事可做 [2013-12-11T21:18:23+00:00] 调试:通过 include_recipe 加载配方 rvm::vagrant [2013-12-11T21:18:23+00:00] 调试:在食谱 rvm 中找到食谱 vagrant [2013-12-11T21:18:23+00:00] 警告:从先前的资源中克隆组 [rvm] 的资源属性 (CHEF-3694) [2013-12-11T21:18:23+00:00] 警告:上一组 [rvm]:/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rvm/recipes/system.rb:33:在“from_file”中 [2013-12-11T21:18:23+00:00] 警告:当前组 [rvm]:/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rvm/recipes/vagrant.rb:34:在“from_file”中 [2013-12-11T21:18:23+00:00] 调试:通过 include_recipe 加载 Redis 配方 [2013-12-11T21:18:23+00:00] 调试:在食谱 redis 中找到默认配方 [2013-12-11T21:18:23+00:00] 调试:通过 include_recipe 加载配方 metachef [2013-12-11T21:18:23+00:00] 调试:在食谱 metachef 中找到默认配方 [2013-12-11T21:18:23+00:00] 调试:通过 include_recipe 加载配方 redis::server [2013-12-11T21:18:23+00:00] 调试:在食谱 redis 中找到配方服务器 [2013-12-11T21:18:23+00:00] 调试:通过 include_recipe 加载配方运行 [2013-12-11T21:18:23+00:00] 调试:在食谱 runit 中找到默认配方 [2013-12-11T21:18:23+00:00] 调试:通过 include_recipe 加载配方 metachef [2013-12-11T21:18:23+00:00] 调试:我没有加载 metachef,因为我已经看过了。 [2013-12-11T21:18:23+00:00] 调试:通过 include_recipe 加载配方 redis::default [2013-12-11T21:18:23+00:00] 调试:我没有加载 redis::default,因为我已经看过了。 [2013-12-11T21:18:23+00:00] 警告:从先前的资源中克隆目录 [/etc/redis] 的资源属性 (CHEF-3694) [2013-12-11T21:18:23+00:00] 警告:上一个目录 [/etc/redis]:/tmp/vagrant-chef-1/chef-solo-1/cookbooks/metachef/definitions/standard_dirs.rb :44:in `from_file 中的块(3 级)' [2013-12-11T21:18:23+00:00] 警告:当前目录 [/etc/redis]:/tmp/vagrant-chef-1/chef-solo-1/cookbooks/metachef/definitions/standard_dirs.rb :44:in `from_file 中的块(3 级)' [2013-12-11T21:18:23+00:00] 调试:编译错误的过滤回溯:/tmp/vagrant-chef-1/chef-solo-1/cookbooks/redis/recipes/server.rb:37:在“from_file”中的“块”中,/tmp/vagrant-chef-1/chef-solo-1/cookbooks/redis/recipes/server.rb:36:在“from_file”中 [2013-12-11T21:18:23+00:00] 调试:编译错误的过滤回溯:/tmp/vagrant-chef-1/chef-solo-1/cookbooks/redis/recipes/server.rb:37:在“from_file”中的“块”中,/tmp/vagrant-chef-1/chef-solo-1/cookbooks/redis/recipes/server.rb:36:在“from_file”中 [2013-12-11T21:18:23+00:00] 调试:编译错误的回溯条目:'/tmp/vagrant-chef-1/chef-solo-1/cookbooks/redis/recipes/server.rb:37 :in `block in from_file'' [2013-12-11T21:18:23+00:00] 调试:编译错误的行号:'37' [2013-12-11T21:18:23+00:00] 调试:重新引发异常:NoMethodError - Chef::Resource::RunitService 的未定义方法“run_state” /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/resource.rb:294:in `method_missing' /tmp/vagrant-chef-1/chef-solo-1/cookbooks/redis/recipes/server.rb:37:in `block in from_file' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/dsl/recipe.rb:71:in `instance_eval' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/dsl/recipe.rb:71:in `method_missing' /tmp/vagrant-chef-1/chef-solo-1/cookbooks/redis/recipes/server.rb:36:in `from_file' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/mixin/from_file.rb:30:in `instance_eval' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/mixin/from_file.rb:30:in `from_file' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/cookbook_version.rb:237:in `load_recipe' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/run_context.rb:151:in `load_recipe' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/run_context/cookbook_compiler.rb:139:in `block in compile_recipes' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/run_context/cookbook_compiler.rb:137:在“每个”中 /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/run_context/cookbook_compiler.rb:137:in `compile_recipes' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/run_context/cookbook_compiler.rb:74:in `compile' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/run_context.rb:86:in `load' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/client.rb:250:in `setup_run_context' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/client.rb:498:in `do_run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/client.rb:199:in `block in run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/client.rb:193:in `fork' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/client.rb:193:in `run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/application.rb:208:in `run_chef_client' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/application/solo.rb:221:in `block in run_application' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/application/solo.rb:213:in `loop' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/application/solo.rb:213:in `run_application' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/application.rb:66:in `run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/bin/chef-solo:25:in `' /opt/chef/bin/chef-solo:23:in `load' /opt/chef/bin/chef-solo:23:in `' [2013-12-11T21:18:23+00:00] 错误:运行异常处理程序 [2013-12-11T21:18:23+00:00] 错误:异常处理程序完成 [2013-12-11T21:18:23+00:00] 致命:堆栈跟踪转储到 /var/chef/cache/chef-stacktrace.out [2013-12-11T21:18:23+00:00] 调试:NoMethodError:Chef::Resource::RunitService 的未定义方法“run_state” /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/resource.rb:294:in `method_missing' /tmp/vagrant-chef-1/chef-solo-1/cookbooks/redis/recipes/server.rb:37:in `block in from_file' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/dsl/recipe.rb:71:in `instance_eval' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/dsl/recipe.rb:71:in `method_missing' /tmp/vagrant-chef-1/chef-solo-1/cookbooks/redis/recipes/server.rb:36:in `from_file' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/mixin/from_file.rb:30:in `instance_eval' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/mixin/from_file.rb:30:in `from_file' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/cookbook_version.rb:237:in `load_recipe' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/run_context.rb:151:in `load_recipe' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/run_context/cookbook_compiler.rb:139:in `block in compile_recipes' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/run_context/cookbook_compiler.rb:137:在“每个”中 /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/run_context/cookbook_compiler.rb:137:in `compile_recipes' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/run_context/cookbook_compiler.rb:74:in `compile' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/run_context.rb:86:in `load' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/client.rb:250:in `setup_run_context' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/client.rb:498:in `do_run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/client.rb:199:in `block in run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/client.rb:193:in `fork' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/client.rb:193:in `run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/application.rb:208:in `run_chef_client' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/application/solo.rb:221:in `block in run_application' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/application/solo.rb:213:in `loop' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/application/solo.rb:213:in `run_application' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/application.rb:66:in `run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/bin/chef-solo:25:in `' /opt/chef/bin/chef-solo:23:in `load' /opt/chef/bin/chef-solo:23:in `' [2013-12-11T21:18:23+00:00] 错误:Chef::Resource::RunitService 的未定义方法“run_state” ==================================================== =============================== /tmp/vagrant-chef-1/chef-solo-1/cookbooks/redis/recipes/server.rb 中的配方编译错误 ==================================================== =============================== 无方法错误 ------------- Chef::Resource::RunitService 的未定义方法“run_state” 食谱跟踪: --------------- /tmp/vagrant-chef-1/chef-solo-1/cookbooks/redis/recipes/server.rb:37:in `block in from_file' /tmp/vagrant-chef-1/chef-solo-1/cookbooks/redis/recipes/server.rb:36:in `from_file' 相关文件内容: ---------------------- /tmp/vagrant-chef-1/chef-solo-1/cookbooks/redis/recipes/server.rb: 30:standard_dirs('redis.server') 做 31:目录:conf_dir,:log_dir,:data_dir 32:结束 33: 34: kill_old_service('redis-server'){ only_if{ File.exists?("/etc/init.d/redis-server") } } 35: 36: runit_service "redis_server" 做 37>> run_state 节点[:redis][:server][:run_state] 38: 选项节点[:redis] 39:结束 40: 41:宣布(:redis,:服务器, 42::端口=>节点[:redis][:服务器][:端口]) 43: [2013-12-11T21:18:21+00:00] 信息:分叉厨师实例收敛...... [2013-12-11T21:18:21+00:00] 调试:分叉成功。等待新厨师 pid:28235 [2013-12-11T21:18:23+00:00] 致命:Chef::Exceptions::ChildConvergeError:Chef 运行进程未成功退出(退出代码 1)
编辑 -
这是运行列表:
config.vm.provision :chef_solo 做 |chef| chef.cookbooks_path = "./cookbooks" #chef.roles_path = "../my-recipes/roles" #chef.data_bags_path = "../my-recipes/data_bags" chef.add_recipe “运行单元” chef.add_recipe "rvm::system" chef.add_recipe "rvm::vagrant" chef.add_recipe "redis::install_from_release" chef.add_recipe "redis::client" # chef.add_recipe “节点” # chef.add_role “网络” # 您还可以指定自定义 JSON 属性: 厨师.json = { 'rvm' => { '红宝石' => ["2.0.0-p353"], 'default_ruby' => "2.0.0-p353", :vagrant => { :system_chef_solo => "/opt/chef/bin/chef-solo" } } } chef.log_level = :debug 结尾
将“runit”食谱放在运行列表的顶部,然后重试。
调查食谱,我发现:
使用时:redis::install_from_package 我得到了一些工作
“runit”食谱似乎有问题。我遇到了同样的问题,甚至将“runit”放在我的运行列表之上。
一个快速的解决方法是改用“redis::install_from_package”。
PS:如果您在 install_from_package 中遇到任何异常,请尝试清理 redis(因为它可能是您之前的尝试生成的):