我正在使用Chef Solo构建一个Vagrant配置(对于Nginx,PHP和Postgres),使用databox cookbook在配置期间在Postgresql中创建数据库。我一直收到以下错误,我追溯到databox::postgresql
最终调用(通过database::paostgresql
)调用postgresql::ruby
食谱。我尝试直接在我的运行列表中运行postgresql::ruby
,它会产生相同的错误。
登录虚拟机并运行sudo /opt/ruby/bin/gem install pg
有效,重新运行vagrant provision
也可以。但是,正如我所理解的那样,postgresql::ruby
任务的重点在于它安装了这个宝石!
以下是Chef运行的输出,该运行只运行 此配方(为了便于阅读,略微编辑):
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扩展。
知道这里发生了什么吗?我没有看到其他人抱怨这个 - 我做错了什么或者没有其他人使用这个食谱?
Chef是版本11.12.8。
我还在postgresql cookbook本身上发布了这个问题,但我认为这可能会在这里得到更多曝光。
答案 0 :(得分:0)
看来这个问题只发生在Chef作为gem安装时,据我所知。
我从使用Chef Gem切换到使用Omnibus,我能够让它正常工作。