chef-infra - Chef-solo 运行列表未扩展以包含 vagrant 和 berkshelf 的依赖项

标签 chef-infra vagrant berkshelf

我正在将 vagrant 与 Chef-solo 和 Berkshelf 一起使用。老实说,我对这三个内容都很陌生,所以可能在这里我无法理解,但我正在尝试制作一本非常简单的 Recipe ,它安装了一个 postgres 数据库。

首先遇到的错误是:“Chef::Exceptions::Exec: package[postgresql-client] (postgresql::client line 36) had an error: Chef::Exceptions::Exec: apt-get -q -y install postgresql-client=9.1+129 返回 100,预期 0"

这是 Cookbooks/transportapi/recipes/default.rb 的内容

#Set up a postgres database

include_recipe "database"
include_recipe "postgresql"

postgresql_database 'thedb' do
  connection(
    :host     => '127.0.0.1',
    :port     => 5432,
    :username => 'postgres',
    :password => node['postgresql']['password']['postgres']
  )
  template 'DEFAULT'
  encoding 'DEFAULT'
  tablespace 'DEFAULT'
  connection_limit '-1'
  owner 'postgres'
  action :create
end

我尝试指定对“database”和“postgresql”的依赖。我还有一个metadata.rb 文件(两个都需要吗?),其中有

depends 'database'
depends 'postgresql'

这些都是 berkshelf 从 opscode 存储库中获取的 Recipe 。我的 Berksfile 如下所示:

site :opscode

cookbook 'database'
cookbook 'postgresql'

cookbook 'transportapi', :path => './cookbooks/transportapi'

这是我尝试执行“vagrant up”时的完整输出

vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'precise32'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[Berkshelf] This version of the Berkshelf plugin has not been fully tested on this version of Vagrant.
[Berkshelf] You should check for a newer version of vagrant-berkshelf.
[Berkshelf] If you encounter any errors with this version, please report them at https://github.com/RiotGames/vagrant-berkshelf/issues
[Berkshelf] You can also join the discussion in #berkshelf on Freenode.
[Berkshelf] Updating Vagrant's berkshelf: '/Users/harrywood/.berkshelf/default/vagrant/berkshelf-20131106-34531-1no9nl5-default'
[Berkshelf] Using postgresql (3.1.0)
[Berkshelf] Using transportapi (0.1.0) at './cookbooks/transportapi'
[Berkshelf] Using apt (2.3.0)
[Berkshelf] Using build-essential (1.4.2)
[Berkshelf] Using openssl (1.1.0)
[Berkshelf] Using database (1.5.2)
[Berkshelf] Using mysql (3.0.12)
[Berkshelf] Using aws (1.0.0)
[Berkshelf] Using xfs (1.1.0)
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] -- 80 => 8080 (adapter 1)
[default] Booting VM...
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] Mounting shared folders...
[default] -- /vagrant
[default] -- /tmp/vagrant-chef-1/chef-solo-1/cookbooks
[default] Running provisioner: chef_solo...
Generating chef JSON and uploading...
Running chef-solo...
stdin: is not a tty
[2013-11-06T01:24:08+00:00] INFO: *** Chef 10.14.2 ***
[2013-11-06T01:24:08+00:00] INFO: Setting the run_list to ["recipe[transportapi]"] from JSON
[2013-11-06T01:24:08+00:00] INFO: Run List is [recipe[transportapi]]
[2013-11-06T01:24:08+00:00] INFO: Run List expands to [transportapi]
[2013-11-06T01:24:08+00:00] INFO: Starting Chef Run for precise32
[2013-11-06T01:24:08+00:00] INFO: Running start handlers
[2013-11-06T01:24:08+00:00] INFO: Start handlers complete.

================================================================================
Error executing action `install` on resource 'package[postgresql-client]'
================================================================================

Chef::Exceptions::Exec
----------------------
apt-get -q -y install postgresql-client=9.1+129 returned 100, expected 0

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

 35: 
 36:   package pg_pack
 37: 

Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/postgresql/recipes/client.rb:36:in `from_file'

package("postgresql-client") do
  retry_delay 2
  retries 0
  recipe_name "client"
  action :install
  cookbook_name :postgresql
  package_name "postgresql-client"
end

[2013-11-06T01:24:16+00:00] ERROR: Running exception handlers
[2013-11-06T01:24:16+00:00] ERROR: Exception handlers complete
[2013-11-06T01:24:17+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2013-11-06T01:24:17+00:00] FATAL: Chef::Exceptions::Exec: package[postgresql-client] (postgresql::client line 36) had an error: Chef::Exceptions::Exec: apt-get -q -y install postgresql-client=9.1+129 returned 100, expected 0
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

也许“apt”没有正确包含在内。我想知道 Chef 运行列表是否应该显示扩展以包含依赖项。它只是说“运行列表扩展为 [transportapi]”,这是我在 vagrant 文件中添加的唯一配方。

最佳答案

当您通过 SSH 连接到虚拟机并在 vagrant 配置 之前执行 apt-get update 时,我猜它会起作用吗?

那么肯定是apt缓存过时的问题。

因此,您应该包含 apt运行列表中的 Recipe 。这会执行apt-get更新(不是在每次 Chef 运行期间,而是每天一次)。

关于chef-infra - Chef-solo 运行列表未扩展以包含 vagrant 和 berkshelf 的依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19802707/

相关文章:

berkshelf - gem install berkshelf 失败,无法在 Centos 6 中构建 gecode 库

在多个服务器上进行 Git pull

ruby - 如何使用 Chef 设置环境变量?

ruby-on-rails - Errno::ETXTBSY: 文本文件繁忙 @ unlink_internal

linux - Vagrant : An AMI must be configured via "ami" (region: #{region})

chef-infra - 如何使用 Berkshelf 管理组织 repo ?

chef-infra - Chef 客户无法使用 Berkshelf 找到 Recipe

ruby - 如何在 IDE(如 Eclipse)中开发和调试 Chef 说明书和 Recipe ?

encryption - 加密的chef数据包json文件,如何解密显示内容?

macos - htop 说 "530G"in "VIRT"for "vagrant ssh"