我在CentOS VM上學習Chef + Test Kitchen,看來每次運行kitchen converge
時,有些程序包會失敗並拋出相同的錯誤:Chef :: Exceptions :: Exec返回1,預計0
Chef::Exceptions::Exec
----------------------
returned 1, expected 0
而所有的錯誤都位於package
資源。例如:
Compiled Resource:
------------------
# Declared in /tmp/kitchen/cookbooks/nginx/recipes/package.rb:39:in `from_file'
package("nginx") do
action :install
retries 0
retry_delay 2
guard_interpreter :default
package_name "nginx"
version "1.0.15-5.el6"
cookbook_name :nginx
recipe_name "package"
end
然而,當我使用kitchen login
並登錄到虛擬機手動運行
yum install nginx
它運行只是確定。另外,有時它在第二次運行kitchen converge
時安裝得很好。
我的配方文件是:
# create vtapp user
user node.default['railsapp']['user'] do
supports :manage_home => true
system true
home "/home/#{node.default['railsapp']['user']}"
shell '/bin/bash'
end
# install git
package 'git'
# install mysql and run the service
mysql_service 'default'
# install redis and run the service
include_recipe 'redis::server'
# install rbenv to vtapp user, and install ruby 2.1.0 along with bundler
include_recipe "ruby_build"
node.default['rbenv']['user_installs'] = [
{
'user' => node.default['railsapp']['user'],
'rubies' => ['2.1.0'],
'gems' => {
'2.1.0' => [
{ 'name' => 'bundler' }
]
}
}
]
include_recipe "rbenv::user"
# install monit
include_recipe "monit"
# install nginx
include_recipe "nginx"
我錯過了什麼?
1.您是否擁有完整的堆棧跟蹤,而不是'#在/tmp/kitchen/cookbooks/nginx/recipes/package.rb:39:in'from_file''中聲明2.當您評論include_recipe 「nginx」? – giosakti
1.是的,但增加了內存分配(o_O)後,錯誤消失2.如果我對該行進行註釋,其他配方偶爾會在編譯到它們各自的「package」資源時失敗。 –