ruby-on-railsruby-on-rails-3chef-infrachef-recipeaws-opsworks

Getting Mixlib::ShellOut::ShellCommandFailed


I get the following error while starting one of the instances on OpsWorks. Does anyone have any ideas about this error?

This is printed before the official error announcement (based on request by sethvargo):

[2014-08-13T17:27:08+00:00] INFO: Processing directory[/srv/www/instance/shared/cached-copy] action 
delete (opsworks_delayed_job::deploy line 48)
[2014-08-13T17:27:08+00:00] INFO: Processing ruby_block[change HOME to /home/deploy for source checkout] action run (opsworks_delayed_job::deploy line 56)
[2014-08-13T17:27:08+00:00] INFO: ruby_block[change HOME to /home/deploy for source checkout] called
[2014-08-13T17:27:08+00:00] INFO: Processing deploy[/srv/www/instance] action deploy (opsworks_delayed_job::deploy line 65)
[2014-08-13T17:27:09+00:00] INFO: deploy[/srv/www/instance] cloning repo git@github.com:xx/xx.git to /srv/www/instance/shared/cached-copy
[2014-08-13T17:27:17+00:00] INFO: deploy[/srv/www/instance] checked out branch: master onto: deploy reference: 714153bbb6a37f0484526cf4da3eda4fcd8df977
[2014-08-13T17:27:17+00:00] INFO: deploy[/srv/www/instance] synchronizing git submodules
[2014-08-13T17:27:17+00:00] INFO: deploy[/srv/www/instance] enabling git submodules
[2014-08-13T17:27:18+00:00] INFO: deploy[/srv/www/instance] set user to deploy
[2014-08-13T17:27:18+00:00] INFO: deploy[/srv/www/instance] set group to www-data
[2014-08-13T17:27:22+00:00] INFO: deploy[/srv/www/instance] copied the cached checkout to /srv/www/instance/releases/20140813172708
[2014-08-13T17:27:23+00:00] INFO: deploy[/srv/www/instance] set user to deploy
[2014-08-13T17:27:23+00:00] INFO: deploy[/srv/www/instance] set group to www-data
[2014-08-13T17:27:23+00:00] INFO: deploy[/srv/www/instance] running callback before_migrate
[2014-08-13T17:27:23+00:00] INFO: deploy[/srv/www/instance] created directories before symlinking: tmp,public,config
[2014-08-13T17:27:23+00:00] INFO: deploy[/srv/www/instance] linked shared paths into current release: system => public/system, pids => tmp/pids, log => log
[2014-08-13T17:27:23+00:00] INFO: deploy[/srv/www/instance] made pre-migration symlinks
[2014-08-13T17:27:24+00:00] INFO: deploy[/srv/www/instance] set user to deploy
[2014-08-13T17:27:24+00:00] INFO: deploy[/srv/www/instance] set group to www-data
[2014-08-13T17:27:24+00:00] INFO: Gemfile detected. Running bundle install.
[2014-08-13T17:27:24+00:00] INFO: sudo su - deploy -c 'cd /srv/www/instance/releases/20140813172708 && /usr/local/bin/bundle install --path /home/deploy/.bundler/instance --without=test development'

Here is the error:

================================================================================
Error executing action `deploy` on resource 'deploy[/srv/www/instance]'
================================================================================


Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '127'

Cookbook Trace:

Cookbook Trace:
---------------
/var/lib/aws/opsworks/cache.stage2/cookbooks/opsworks_commons/libraries/shellout.rb:8:in `shellout'
/var/lib/aws/opsworks/cache.stage2/cookbooks/rails/libraries/rails_configuration.rb:41:in `bundle'
/var/lib/aws/opsworks/cache.stage2/cookbooks/deploy/definitions/opsworks_deploy.rb:103:in `block (3 levels) in from_file'

Resource declaration is:

Resource Declaration:
---------------------
# In /var/lib/aws/opsworks/cache.stage2/cookbooks/deploy/definitions/opsworks_deploy.rb

65:     deploy deploy[:deploy_to] do
66:       provider Chef::Provider::Deploy.const_get(deploy[:chef_provider])
67:       keep_releases deploy[:keep_releases]
68:       repository deploy[:scm][:repository]
69:       user deploy[:user]
70:       group deploy[:group]
71:       revision deploy[:scm][:revision]
72:       migrate deploy[:migrate]
73:       migration_command deploy[:migrate_command]
74:       environment deploy[:environment].to_hash
75:       create_dirs_before_symlink( deploy[:create_dirs_before_symlink] )
76:       symlink_before_migrate( deploy[:symlink_before_migrate] )
77:       action deploy[:action]
78: 
79:       if deploy[:application_type] == 'rails'
80:         restart_command "sleep #{deploy[:sleep_before_restart]} && #{node[:opsworks][:rails_stack][:restart_command]}"
81:       end
82: 

Solution

  • With credit to Seth Vargo, the problem was that the bundler gem was not being installed by OpsWorks. The Chef version is 11.10. We had to add the bundler gem manually to the default Chef setup file.