我正與Chef Solo一起構建Vagrant配置(對於Nginx,PHP和Postgres),使用databox cookbook在配置期間在Postgresql中創建數據庫。我不斷收到下面的錯誤,我跟蹤到databox::postgresql
的最終電話(通過database::paostgresql
)撥打postgresql::ruby
配方。我嘗試直接在我的運行列表中運行postgresql::ruby
,並且它會產生相同的錯誤。使用廚師安裝Postgres Gem時出錯
登錄到VM並運行sudo /opt/ruby/bin/gem install pg
工程,並且重新運行vagrant provision
也可以工作。然而,據我所知,postgresql::ruby
任務的全部重點在於它安裝了這顆寶石!
下面是從運行只有這個食譜廚師運行的輸出(爲便於閱讀,而稍加編輯):
Running chef-solo...
[2014-07-23T19:33:52+00:00] INFO: Forking chef instance to converge...
[2014-07-23T19:33:52+00:00] INFO: *** Chef 11.12.8 ***
[2014-07-23T19:33:52+00:00] INFO: Chef-client pid: 1627
[2014-07-23T19:33:53+00:00] INFO: Setting the run_list to ["postgresql::ruby"] from CLI options
[2014-07-23T19:33:53+00:00] INFO: Run List is [recipe[postgresql::ruby]]
[2014-07-23T19:33:53+00:00] INFO: Run List expands to [postgresql::ruby]
[2014-07-23T19:33:53+00:00] INFO: Starting Chef Run for vm
[2014-07-23T19:33:53+00:00] INFO: Running start handlers
[2014-07-23T19:33:53+00:00] INFO: Start handlers complete.
[2014-07-23T19:33:57+00:00] INFO: execute[apt-get update] ran successfully
[2014-07-23T19:34:09+00:00] INFO: package[ncurses-dev] is a virtual package, actually acting on package[libncurses5-dev]
================================================================================
Error executing action `install` on resource 'chef_gem[pg]'
================================================================================
LoadError
---------
cannot load such file -- pg
Cookbook Trace:
---------------
/tmp/vagrant-chef-3/chef-solo-1/cookbooks/postgresql/recipes/ruby.rb:25:in `from_file'
Resource Declaration:
---------------------
# In /tmp/vagrant-chef-3/chef-solo-1/cookbooks/postgresql/recipes/ruby.rb
58: chef_gem "pg"
59: rescue Gem::Installer::ExtensionBuildError => e
Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-3/chef-solo-1/cookbooks/postgresql/recipes/ruby.rb:58:in `rescue in from_file'
chef_gem("pg") do
provider Chef::Provider::Package::Rubygems
action :install
retries 0
retry_delay 2
guard_interpreter :default
package_name "pg"
version "0.17.1"
cookbook_name :postgresql
recipe_name "ruby"
end
================================================================================
Recipe Compile Error in /tmp/vagrant-chef-3/chef-solo-1/cookbooks/postgresql/recipes/ruby.rb
================================================================================
LoadError
---------
chef_gem[pg] (postgresql::ruby line 58) had an error: LoadError: cannot load such file -- pg
Cookbook Trace:
---------------
/tmp/vagrant-chef-3/chef-solo-1/cookbooks/postgresql/recipes/ruby.rb:25:in `from_file'
Relevant File Content:
----------------------
/tmp/vagrant-chef-3/chef-solo-1/cookbooks/postgresql/recipes/ruby.rb:
18: # limitations under the License.
19: #
20:
21: # Load the pgdgrepo_rpm_info method from libraries/default.rb
22: ::Chef::Recipe.send(:include, Opscode::PostgresqlHelpers)
23:
24: begin
25>> require 'pg'
26: rescue LoadError
27:
28: if platform_family?('ubuntu', 'debian')
29: e = execute 'apt-get update' do
30: action :nothing
31: end
32: e.run_action(:run) unless ::File.exists?('/var/lib/apt/periodic/update-success-stamp')
33: end
34:
[2014-07-23T19:34:29+00:00] ERROR: Running exception handlers
[2014-07-23T19:34:29+00:00] ERROR: Exception handlers complete
[2014-07-23T19:34:29+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2014-07-23T19:34:29+00:00] ERROR: chef_gem[pg] (postgresql::ruby line 58) had an error: LoadError: cannot load such file -- pg
[2014-07-23T19:34:29+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.
我沒有做這個沒有運行任何異常 - 虛擬機是股票使用Packer構建的Vagrant Ubuntu 14.04 x64映像 - Packer對映像所做的唯一一件事是安裝Chef和VirtualBox擴展。
任何想法這裏發生了什麼?我沒有看到其他人抱怨這個 - 我做錯了什麼,或者沒有人使用這個配方?
廚師是版本11.12.8。
我也貼這是在postgresql cookbook本身的問題,但我想它可能在這裏得到更多的曝光。
您是否閱讀過關於「ruby」配方的重要提示?你把它包含在你的'run_list'中嗎? https://github.com/hw-cookbooks/postgresql#ruby – sethvargo
@sethvargo是的,我讀過它,但在那裏鏈接的問題並沒有描述我遇到的問題。它描述了一個不同的錯誤。至於'run_list',我已經在問題中說過,當我包含'postgresql :: ruby'或者當我包含任何其他包含它的配方時會發生這種情況。 –