2012-01-20 45 views
5

在vagrant上運行Ubuntu 11.04,mac os x 10.7.2。運行廚師服務器。廚師沒有運行apt(apt-get update)配方。 Apt返回100

嘗試安裝PostgreSQL的社區廚師食譜,我得到以下錯誤,即使我基地的角色看起來是這樣的(我加入了易配方嘗試更新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的,做廚師客戶端的另一個運行安裝的Postgres沒有問題。關於爲什麼apt recipe沒有運行的任何想法? (我也知道它沒有運行,因爲apt-get的時間戳文件不是在ubuntu中創建的)。任何幫助將非常感激。

回答

6

所以,從你的印刷錯誤,似乎運行命令

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

失敗。

但你說,如果你運行

apt-get update 

,然後再重新設置,它工作正常?

我的預感是,當您第一次運行廚師時,您所請求的postgresql客戶端版本不在您下載的apt軟件包列表中,但運行apt-get update會找到該版本。

我看到您首先運行base_server配方,是否將apt存儲庫添加到列表中?

無論如何,我會建議在運行postgres配方之前運行apt-get update,這可能適合放入base_server配方,我想。

+5

謝謝,這是適當的配方應該做的。問題是「即使適當的配方應該這樣做,爲什麼不更新」 – Andres

+0

您是否使用基於https://github.com/opscode/cookbooks/blob/master/apt/的配方?食譜/ default.rb?如果是這樣,那麼只需設置從其他食譜調用apt-get-update的能力(注意第29行的註釋),但在此配方運行時不會對第33行的'action:nothing'執行調用。 –

+2

在配方運行後使用apt-get update執行的一個例子可以在https://github.com/opscode/cookbooks/blob/master/rsyslog/recipes/default.rb#L28 –

相關問題