application_ruby クックブックを使用して、Chef がセットアップしているサーバーに Rails アプリをデプロイしようとしています。Chef-client が running のポイントに到達すると、bundle install
bundler が見つからないと言ってクラッシュします。これは、このサーバーで RVM を使用しているという事実と関係があるのではないかと思いますが、それについてどうすればよいかわかりません。
これが私のアプリケーションレシピです:
database_name = "app_#{node.chef_environment}"
api_deploy_key = Chef::EncryptedDataBagItem.load('keys', 'app_repository')["deploy_key"]
application "my_app" do
path "/var/www"
owner 'ubuntu'
repository "git@github.com:my_account/app.git"
revision node.chef_environment == "production" ? "master" : "develop"
deploy_key api_deploy_key
rails do
gems [['Bundler', '1.3.4']]
database_master_role 'db_master'
database do
database database_name
username "ubuntu"
password Chef::EncryptedDataBagItem.load('passwords', 'db')["password"]
end
bundler true
precompile_assets true
end
end
そして、これはそれが生成するエラーです:
================================================================================
Error executing action `run` on resource 'execute[bundle install --path=vendor/bundle --deployment --without development test cucumber production]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of bundle install --path=vendor/bundle --deployment --without development test cucumber production ----
STDOUT:
STDERR: /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:296:in `to_specs': Could not find 'bundler' (>= 0) among 175 total gem(s) (Gem::LoadError)
from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:307:in `to_spec'
from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /usr/local/rvm/gems/ruby-1.9.3-p125@global/bin/bundle:22:in `<main>'
from /usr/local/rvm/gems/ruby-1.9.3-p125/bin/ruby_noexec_wrapper:14:in `eval'
from /usr/local/rvm/gems/ruby-1.9.3-p125/bin/ruby_noexec_wrapper:14:in `<main>'
---- End output of bundle install --path=vendor/bundle --deployment --without development test cucumber production ----
Ran bundle install --path=vendor/bundle --deployment --without development test cucumber production returned 1
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/application_ruby/providers/rails.rb
86: execute "#{bundle_command} install --path=vendor/bundle #{bundler_deployment ? "--deployment " : ""}--without #{common_groups}" do
87: cwd new_resource.release_path
88: user new_resource.owner
89: environment new_resource.environment
90: end
91: else
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/application_ruby/providers/rails.rb:86:in `block in class_from_file'
execute("bundle install --path=vendor/bundle --deployment --without development test cucumber production") do
action "run"
retries 0
retry_delay 2
command "bundle install --path=vendor/bundle --deployment --without development test cucumber production"
backup 5
cwd "/var/www/releases/30858f319060ca556b5109aa6d0ac64afa3f8e38"
environment {"RAILS_ENV"=>"staging", "PATH"=>"/usr/local/rvm/rubies/ruby-1.9.3-p125/bin:/usr/local/rvm/gems/ruby-1.9.3-p125/bin:/usr/local/rvm/gems/ruby-1.9.3-p125@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p125/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"}
returns 0
user "ubuntu"
cookbook_name "my_app"
end
falseに設定rollback_on_error
すると、チェックアウトしたコード ディレクトリに手動で移動し、bundle install
問題なく実行できます。
ここで何が問題になっていますか?どうすれば修正できますか?