【问题标题】:Chef isn't running the apt (apt-get update) recipe. Apt returns 100Chef 没有运行 apt (apt-get update) 配方。 Apt 返回 100
【发布时间】:2012-02-14 18:41:38
【问题描述】:

在 vagrant、mac os x 10.7.2 上运行 Ubuntu 11.04。运行厨师服务器。

尝试安装 postgresql 社区厨师食谱时,我收到以下错误,即使我的基本角色看起来像这样(我添加了 apt 食谱以尝试更新 apt-get):

name "base"
description "The base role for systems"
run_list(
        "recipe[apt]",
        "recipe[vim]"
)

尝试做厨师跑步:

$ vagrant reload db1dev
[db1dev] Attempting graceful shutdown of linux...
[db1dev] Preparing host only network...
[db1dev] Clearing any previously set forwarded ports...
[db1dev] Forwarding ports...
[db1dev] -- ssh: 22 => 2222 (adapter 1)
[db1dev] Cleaning previously set shared folders...
[db1dev] Creating shared folders metadata...
[db1dev] Running any VM customizations...
[db1dev] Booting VM...
[db1dev] Waiting for VM to boot. This can take a few minutes.
[db1dev] VM booted and ready for use!
[db1dev] Enabling host only network...
[db1dev] Mounting shared folders...
[db1dev] -- v-root: /vagrant
[db1dev] Running provisioner: Vagrant::Provisioners::ChefClient...
[db1dev] Creating folder to hold client key...
[db1dev] Uploading chef client validation key...
[db1dev] Generating chef JSON and uploading...
[db1dev] Running chef-client...
[db1dev] stdin: is not a tty
: stderr
[db1dev] [Thu, 19 Jan 2012 21:44:45 -0800] INFO: *** Chef 0.10.2 ***
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:46 -0800] INFO: Client key /etc/chef/client.pem is not present - registering
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:46 -0800] INFO: HTTP Request Returned 404 Not Found: Cannot load node dev-vagrant-db1-andres
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:47 -0800] INFO: Setting the run_list to ["role[base]", "role[db_master]"] from JSON
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:47 -0800] INFO: Run List is [role[base], role[db_master]]
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:47 -0800] INFO: Run List expands to [base_server, vim, postgresql::server]
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:47 -0800] INFO: Starting Chef Run for dev-vagrant-db1-andres
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:47 -0800] INFO: Loading cookbooks [base_server, openssl, postgresql, vim]
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:47 -0800] INFO: Removing cookbooks/apt/resources/repository.rb from the cache; its cookbook is no longer needed on this client.
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:47 -0800] INFO: Removing cookbooks/apt/metadata.rb from the cache; its cookbook is no longer needed on this client.
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:47 -0800] INFO: Removing cookbooks/apt/providers/repository.rb from the cache; its cookbook is no longer needed on this client.
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:47 -0800] INFO: Removing cookbooks/apt/recipes/cacher.rb from the cache; its cookbook is no longer needed on this client.
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:47 -0800] INFO: Removing cookbooks/apt/recipes/cacher-client.rb from the cache; its cookbook is no longer needed on this client.
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:47 -0800] INFO: Removing cookbooks/apt/recipes/default.rb from the cache; its cookbook is no longer needed on this client.
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:47 -0800] INFO: Removing cookbooks/apt/metadata.json from the cache; its cookbook is no longer needed on this client.
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:47 -0800] INFO: Removing cookbooks/apt/README.md from the cache; its cookbook is no longer needed on this client.
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:47 -0800] INFO: Storing updated cookbooks/base_server/recipes/default.rb in the cache.
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:47 -0800] INFO: Storing updated cookbooks/base_server/README.rdoc in the cache.
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:47 -0800] INFO: Storing updated cookbooks/base_server/metadata.rb in the cache.
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:47 -0800] INFO: Processing package[postgresql-client] action install (postgresql::client line 37)
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:48 -0800] ERROR: package[postgresql-client] (postgresql::client line 37) has had an error
[Thu, 19 Jan 2012 21:44:48 -0800] ERROR: Running exception handlers
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:48 -0800] FATAL: Saving node information to /srv/chef/file_store/failed-run-data.json
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:48 -0800] ERROR: Exception handlers complete
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:48 -0800] FATAL: Stacktrace dumped to /srv/chef/file_store/chef-stacktrace.out
: stdout
[db1dev] [Thu, 19 Jan 2012 21:44:48 -0800] FATAL: Chef::Exceptions::Exec: package[postgresql-client] (postgresql::client line 37) had an error: apt-get -q -y install postgresql-client=8.4.8-0ubuntu0.10.04 returned 100, expected 0
: stdout
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

chef-client -c /etc/chef/client.rb -j /etc/chef/dna.json

The output of the command prior to failing is outputted below:

[no output]

如果我从服务器内部手动执行 $sudo apt-get update,则再次运行 chef-client install postgres 没有问题。关于为什么 apt 配方没有运行的任何想法? (我也知道它没有运行,因为 apt-get 的时间戳文件不是在 ubuntu 中创建的)。任何帮助将不胜感激。

【问题讨论】:

    标签: ruby ubuntu-11.04 apt-get chef-infra chef-recipe


    【解决方案1】:

    所以,从你打印的错误来看,似乎是在运行命令

    apt-get -q -y install postgresql-client=8.4.8-0ubuntu0.10.04
    

    失败了。

    但你说如果你跑

    apt-get update
    

    先,然后重新配置,它工作正常吗?

    我的预感是,当您第一次运行 chef 时,您请求的 postgresql 客户端版本不在您下载的 apt 包列表中,但运行 apt-get update 会找到该版本。

    我看到您首先运行base_server 配方,是否将 apt 存储库添加到列表中?

    无论如何,我建议在运行 postgres 配方之前运行 apt-get update,这可能适合放入我认为的 base_server 配方中。

    【讨论】:

    • 谢谢,这就是 apt 配方应该做的。问题是“即使 apt 配方应该这样做,为什么不更新 apt”
    • 您是否使用基于github.com/opscode/cookbooks/blob/master/apt/recipes/default.rb 的配方?如果是这样,那只是设置了从其他配方调用 apt-get-update 的能力(请注意第 29 行的注释),但在此配方运行时不会运行调用 do to the action :nothing on line 33.跨度>
    • 在配方运行后使用 apt-get update 执行的示例可以在github.com/opscode/cookbooks/blob/master/rsyslog/recipes/…看到
    • 啊,这很有道理。谢谢!
    • 你总是可以只做execute "apt-get update"。默认情况下,chef 中的execute 命令只会运行
    猜你喜欢
    • 2016-10-26
    • 2021-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-04
    • 2020-12-22
    • 1970-01-01
    相关资源
    最近更新 更多