Question

I am learning Chef + Test Kitchen on a CentOS VM at the moment and it seems that every time I run kitchen converge, some packages fail and throw the same error:

Chef::Exceptions::Exec
----------------------

returned 1, expected 0

And ALL of the errors are located in the package resource. For example:

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

However, when I login to the VM using kitchen login and manually run

yum install nginx

It runs just OK. Also, sometimes it just installs fine when I run kitchen converge for the second time.

My recipe file is:

# 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"

Did I miss something?

Was it helpful?

Solution

Well, as crazy as it seems, after I increased the memory allocation for Vagrant to 1024 MB as is described in the link below:

https://github.com/test-kitchen/kitchen-vagrant/issues/22

The intermittent issue above suddenly gone...

update:

I have repeatedly run the full kitchen test command with success after I increased the memory allocation :-)

update (2):

I have delved more about Chef and another possible cause is the timeout set within Chef to execute an action, 15 mins if I recall correctly. Possible solutions I have used are 1) Installing proxy server to accelerate download times, 2) Increasing internet bandwidth, 3) Allow vagrant to allocate more CPU cores to the VM.

You must also pay attention about the minimum memory required for the application. For example, I had installed ZenOSS with Chef, which require 3 GB memory at minimum, and kept failing with the error code above if I allocated memory below that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top