Назад | Перейти на главную страницу

Как установить Redis с Chef?

Я пытаюсь установить Redis с помощью Chef. Я думаю, это просто, так как я хочу иметь только конфигурацию по умолчанию.

Итак, я добавляю в Berksfile:

site :opscode

cookbook 'apt'
cookbook 'node'
cookbook 'rvm', :git => "https://github.com/fnichol/chef-rvm"
cookbook 'runit'
cookbook 'redis'

Затем я бегу: бродяга

Но я понял:

2013-12-11T21:18:23+00:00] DEBUG: chef_gem[rvm] is already installed - nothing to do
[2013-12-11T21:18:23+00:00] DEBUG: Loading Recipe rvm::vagrant via include_recipe
[2013-12-11T21:18:23+00:00] DEBUG: Found recipe vagrant in cookbook rvm
[2013-12-11T21:18:23+00:00] WARN: Cloning resource attributes for group[rvm] from prior resource (CHEF-3694)
[2013-12-11T21:18:23+00:00] WARN: Previous group[rvm]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/rvm/recipes/system.rb:33:in `from_file'
[2013-12-11T21:18:23+00:00] WARN: Current  group[rvm]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/rvm/recipes/vagrant.rb:34:in `from_file'
[2013-12-11T21:18:23+00:00] DEBUG: Loading Recipe redis via include_recipe
[2013-12-11T21:18:23+00:00] DEBUG: Found recipe default in cookbook redis
[2013-12-11T21:18:23+00:00] DEBUG: Loading Recipe metachef via include_recipe
[2013-12-11T21:18:23+00:00] DEBUG: Found recipe default in cookbook metachef
[2013-12-11T21:18:23+00:00] DEBUG: Loading Recipe redis::server via include_recipe
[2013-12-11T21:18:23+00:00] DEBUG: Found recipe server in cookbook redis
[2013-12-11T21:18:23+00:00] DEBUG: Loading Recipe runit via include_recipe
[2013-12-11T21:18:23+00:00] DEBUG: Found recipe default in cookbook runit
[2013-12-11T21:18:23+00:00] DEBUG: Loading Recipe metachef via include_recipe
[2013-12-11T21:18:23+00:00] DEBUG: I am not loading metachef, because I have already seen it.
[2013-12-11T21:18:23+00:00] DEBUG: Loading Recipe redis::default via include_recipe
[2013-12-11T21:18:23+00:00] DEBUG: I am not loading redis::default, because I have already seen it.
[2013-12-11T21:18:23+00:00] WARN: Cloning resource attributes for directory[/etc/redis] from prior resource (CHEF-3694)
[2013-12-11T21:18:23+00:00] WARN: Previous directory[/etc/redis]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/metachef/definitions/standard_dirs.rb:44:in `block (3 levels) in from_file'
[2013-12-11T21:18:23+00:00] WARN: Current  directory[/etc/redis]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/metachef/definitions/standard_dirs.rb:44:in `block (3 levels) in from_file'
[2013-12-11T21:18:23+00:00] DEBUG: filtered backtrace of compile error: /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'
[2013-12-11T21:18:23+00:00] DEBUG: filtered backtrace of compile error: /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'
[2013-12-11T21:18:23+00:00] DEBUG: backtrace entry for compile error: '/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] DEBUG: Line number of compile error: '37'
[2013-12-11T21:18:23+00:00] DEBUG: Re-raising exception: NoMethodError - undefined method `run_state' for Chef::Resource::RunitService
/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:in `each'
  /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] ERROR: Running exception handlers
[2013-12-11T21:18:23+00:00] ERROR: Exception handlers complete
[2013-12-11T21:18:23+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2013-12-11T21:18:23+00:00] DEBUG: NoMethodError: undefined method `run_state' for Chef::Resource::RunitService
/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:in `each'
/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] ERROR: undefined method `run_state' for Chef::Resource::RunitService

================================================================================
Recipe Compile Error in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/redis/recipes/server.rb
================================================================================


NoMethodError
-------------
undefined method `run_state' for Chef::Resource::RunitService


Cookbook Trace:
---------------
  /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'


Relevant File Content:
----------------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/redis/recipes/server.rb:

 30:  standard_dirs('redis.server') do
 31:    directories   :conf_dir, :log_dir, :data_dir
 32:  end
 33:
 34:  kill_old_service('redis-server'){ only_if{ File.exists?("/etc/init.d/redis-server") } }
 35:
 36:  runit_service "redis_server" do
 37>>   run_state     node[:redis][:server][:run_state]
 38:    options       node[:redis]
 39:  end
 40:
 41:  announce(:redis, :server,
 42:    :port => node[:redis][:server][:port])
 43:


[2013-12-11T21:18:21+00:00] INFO: Forking chef instance to converge...
[2013-12-11T21:18:21+00:00] DEBUG: Fork successful. Waiting for new chef pid: 28235
[2013-12-11T21:18:23+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

РЕДАКТИРОВАТЬ -

Это список выполнения:

  config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = "./cookbooks"
    #chef.roles_path = "../my-recipes/roles"
    #chef.data_bags_path = "../my-recipes/data_bags"
    chef.add_recipe "runit"
    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 "node"
    # chef.add_role "web"

    # You may also specify custom JSON attributes:
    chef.json = { 
      'rvm' => {
         'rubies' => ["2.0.0-p353"],
         'default_ruby' => "2.0.0-p353",
         :vagrant => { :system_chef_solo => "/opt/chef/bin/chef-solo" }
      }
    }

    chef.log_level = :debug 
  end


Поместите поваренную книгу «runit» в начало списка выполнения и попробуйте еще раз.

Изучая поваренную книгу, я обнаружил:

recipe           "redis::default",                     "Base configuration for redis"
recipe           "redis::install_from_package",        "Install From Ubuntu Package -- easy but lags in version"
recipe           "redis::install_from_release",        "Install From Release"
recipe           "redis::server",                      "Redis server with runit service"
recipe           "redis::client",  

При использовании: redis :: install_from_package у меня что-то работает

Вроде проблема с кулинарной книгой "runit". У меня была такая же проблема, даже если я поставил «runit» поверх моего списка запуска.

Для быстрого исправления можно использовать "redis :: install_from_package".

PS: Если вы получите какое-либо исключение с install_from_package, попробуйте очистить redis (потому что он мог быть сгенерирован из ваших предыдущих попыток):

sudo apt-get purge  redis-server
rm -rf /etc/redis