簡體   English   中英

為什么chef_gem食譜是通過chef-solo而不是通過vagrant工作的

[英]why chef_gem recipe works from chef-solo and not through vagrant

資源chef_gemchef-solo 一起工作,但不適用於vagrant up

myapp / Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.hostname = "my-hostname"
  config.vm.box = "ubn1204-chef-gemsources-i386"
  config.vm.network :private_network, ip: "33.33.33.10"
  config.vm.boot_timeout = 120
  config.berkshelf.enabled = true

  config.vm.provision :chef_solo do |chef|
    chef.json = {
      :mysql => {
        :server_root_password => 'rootpass',
        :server_debian_password => 'debpass',
        :server_repl_password => 'replpass'
      }
    }
    chef.run_list = [
      "recipe[myface::mysql_gem]"
    ]
  end
end

* myapp /食譜/mysql_gem.rb*

%w{mysql-client libmysqlclient-dev make}.each do |pack|
  package pack do
    action :nothing
  end.run_action(:install)
end
g = chef_gem "mysql" do
  action :nothing
end
g.run_action(:install)

當執行vagrant up我得到以下錯誤

[2014-01-22T15:21:06+00:00] INFO: Forking chef instance to converge...
[2014-01-22T15:21:07+00:00] INFO: *** Chef 11.8.2 ***
[2014-01-22T15:21:07+00:00] INFO: Chef-client pid: 1162
[2014-01-22T15:21:09+00:00] INFO: Setting the run_list to ["recipe[myface::mysql_gem]"] from JSON
[2014-01-22T15:21:09+00:00] INFO: Run List is [recipe[myface::mysql_gem]]
[2014-01-22T15:21:09+00:00] INFO: Run List expands to [myface::mysql_gem]
[2014-01-22T15:21:09+00:00] INFO: Starting Chef Run for myface-berkshelf
[2014-01-22T15:21:09+00:00] INFO: Running start handlers
[2014-01-22T15:21:09+00:00] INFO: Start handlers complete.
[2014-01-22T15:22:54+00:00] WARN:  failed to find gem mysql (>= 0) from [http://rubygems.org/]
[2014-01-22T15:22:54+00:00] ERROR: Running exception handlers
[2014-01-22T15:22:54+00:00] ERROR: Exception handlers complete
[2014-01-22T15:22:54+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2014-01-22T15:22:54+00:00] ERROR: chef_gem[mysql] (myface::mysql_gem line 6) had an error: ArgumentError: Illformed requirement [""]

================================================================================
Error executing action `install` on resource 'chef_gem[mysql]'
================================================================================


ArgumentError
-------------
Illformed requirement [""]


Cookbook Trace:
---------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/myface/recipes/mysql_gem.rb:9:in `from_file'


Resource Declaration:
---------------------
# In /tmp/vagrant-chef-1/chef-solo-1/cookbooks/myface/recipes/mysql_gem.rb

  6: g = chef_gem "mysql" do
  7:   action :nothing
  8: end
  9: g.run_action(:install)


Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/myface/recipes/mysql_gem.rb:6:in `from_file'

chef_gem("mysql") do
  provider Chef::Provider::Package::Rubygems
  action [:nothing]
  retries 0
  retry_delay 2
  package_name "mysql"
  cookbook_name :myface
  recipe_name "mysql_gem"
end




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


ArgumentError
-------------
chef_gem[mysql] (myface::mysql_gem line 6) had an error: ArgumentError: Illformed requirement [""]


Cookbook Trace:
---------------
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/myface/recipes/mysql_gem.rb:9:in `from_file'


Relevant File Content:
----------------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/myface/recipes/mysql_gem.rb:

  2:    package pack do
  3:      action :nothing
  4:    end.run_action(:install)
  5:  end
  6:  g = chef_gem "mysql" do
  7:    action :nothing
  8:  end
  9>> g.run_action(:install) 10:  


[2014-01-22T15:21:06+00:00] INFO: Forking chef instance to converge...
[2014-01-22T15:22:54+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

但是我進入無業游民的VM vagrant ssh

執行vagrant $ sudo chef-solo -c /vagrant/solo.rb -j /vagrant/aux.rb 可以正常工作。

什么時候

/vagrant/aux.rb

{
    "mysql": {
    "server_root_password": "rootpass",
    "server_debian_password": "debpass",
    "server_repl_password": "replpass"
},
    "run_list": [ "recipe[myface::mysql_gem]" ]
}

/vagrant/solo.rb

file_cache_path    "/var/chef/cache"
file_backup_path   "/var/chef/backup"
cookbook_path ["/tmp/vagrant-chef-1/chef-solo-1/cookbooks"]
log_level :info
verbose_logging    true

encrypted_data_bag_secret "/tmp/encrypted_data_bag_secret"

有人知道為什么直接從chef-solo而不是無業游民就可以正常工作嗎?

工具版本

  • 紅寶石1.9.3p392
  • 虛盒4.3.6
  • 廚師:11.8.2
  • Vagrant 1.3.5插件
  • 流浪漢-伯克謝爾夫(1.3.7)
  • vagrantbox Ubuntu 12.04

這是一個已知的廚師錯誤-CHEF-3912

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM