Chef

如何使用 Chef 安裝 Redis?

  • July 22, 2016

我正在嘗試使用 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::default”,“redis 的基本配置”
配方“redis::install_from_package”,“從 Ubuntu 包安裝——簡單但版本滯後”
配方“redis::install_from_release”,“從發行版安裝”
recipe "redis::server", "Redis server with runit service"
配方“redis::client”, 

使用時:redis::install_from_package 我得到了一些工作

引用自:https://serverfault.com/questions/560778