Take the 2-minute tour ×

I am trying to deploy ruby on rails application with chef, I am facing an issue. During the code deployment I need to run bundle update/bundle install. I am trying to figure out how do I run the command. I tried with "bundler true" the chef threw error while deploying. So I wrote a function

execute "bundler" do
command "bundle install"
ssh_wrapper "/home/ubuntu/.ssh/chef_ssh_deploy_wrapper.sh"

Since my gemfile includes gems and code repo's for github and other bit bucket accounts, it stops to add it to known_hosts and chef fails to move further.

How do avoid such issue and do a smooth deployment. Kindly suggest.

share|improve this question

2 Answers 2

Typically I would use

  • chef for provisioning servers
  • capistrano for deploying code (including installing gems)

That being said you can configure the user account with ssh config to not have strict checking

# files/ssh_config
Host github.com
    StrictHostKeyChecking no    

# recipes/user_setup.rb
user = "someuser"
cookbook_file "/home/#{user}/.ssh/config" do
  source "ssh_config"
  owner "#{user}"
  group "#{user}"
  mode "0600"

You may run into issues trying to bundle install gems during chef deployment, as chef is using its own isolated ruby install for the purpose of executing chef scripts, you don't want to bundle into this ruby, but into the installed ruby you have specified

Again I would recommend using capistrano for deployment

Also recommend using the ubuntu user for provisioning using chef, but a secondary account for running your rails application, capistrano would deploy using this application account

share|improve this answer

Your issue comes from not having established an initial ssh connections to github, etc. I use the following configuration in my .ssh/config file:

Host github StrictHostKeyChecking no UserKnownHostsFile=/dev/null LogLevel=ERROR User yourdeployuser IdentityFile ~/.ssh/somefile.pem

The gist of this, is that you're expressly telling ssh that you don't need, or want to make use of the known hosts feature in ssh when connecting to github.

share|improve this answer

Your Answer


