简体   繁体   English

使用Chef Cookbook EC部署ruby on rails应用程序

[英]ruby on rails app deployment using chef cookbook ec

I am trying to deploy ruby on rails application with chef, I am facing an issue. 我正在尝试与厨师一起在Rails应用程序上部署ruby,但是我遇到了一个问题。 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. 我尝试使用“ bundler true”,在部署时厨师抛出了错误。 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. 由于我的gemfile包含适用于github和其他位存储桶帐户的gems和代码存储库,因此它停止将其添加到known_hosts,并且Chef无法继续。

How do avoid such issue and do a smooth deployment. 如何避免此类问题并顺利进行部署。 Kindly suggest. 请提示。

Typically I would use 通常我会用

  • chef for provisioning servers 负责配置服务器的厨师
  • capistrano for deploying code (including installing gems) capistrano用于部署代码(包括安装gem)

That being said you can configure the user account with ssh config to not have strict checking 话虽如此,您可以使用ssh config来配置用户帐户,而不必进行严格检查

# 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 您可能会在厨师部署期间尝试捆绑安装gem时遇到问题,因为厨师出于执行厨师脚本的目的而使用其自己的隔离ruby安装,您不想捆绑到该ruby中,而是捆绑到您指定的已安装ruby中

Again I would recommend using capistrano for deployment 同样,我建议使用capistrano进行部署

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 还建议使用ubuntu用户使用Chef进行配置,但是要使用第二个帐户来运行Rails应用程序,capistrano将使用此应用程序帐户进行部署

Your issue comes from not having established an initial ssh connections to github, etc. I use the following configuration in my .ssh/config file: 您的问题来自未建立与github的初始ssh连接等。我在.ssh / config文件中使用以下配置:

Host github StrictHostKeyChecking no UserKnownHostsFile=/dev/null LogLevel=ERROR User yourdeployuser IdentityFile ~/.ssh/somefile.pem 主机github StrictHostKeyChecking否UserKnownHostsFile = / dev / null LogLevel = ERROR用户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. 要点是,您要明确告诉ssh不需要,或者要在连接github时使用ssh中的已知主机功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM