0

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

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.

2 Answers 2

1

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

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

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.