简体   繁体   English

厨师部署?

[英]chef deployment?

I'm interested in switching from Capistrano to Chef, but am having a few issues putting all the pieces together. 我有兴趣从Capistrano转换为Chef,但我有一些问题将所有部分组合在一起。

I've followed http://wiki.opscode.com/display/chef/Quick+Start and am able to start EC2 instances with knife . 我已经关注了http://wiki.opscode.com/display/chef/Quick+Start并且能够knife启动EC2实例。 As far as code deployment, it looks as though I want to be doing what's in http://wiki.opscode.com/display/chef/Deploy+Resource , the only problem is, nowhere on that page does it mention in what directory/file the deploy /to/path code block should go. 就代码部署而言,看起来好像我想做http://wiki.opscode.com/display/chef/Deploy+Resource中的内容 ,唯一的问题是,该页面上没有提到它在哪个目录中提到/ file deploy /to/path代码块应该去。

Another issue I'm having is understanding how to deploy code changes after the server has been set up. 我遇到的另一个问题是了解如何在设置服务器后部署代码更改。 Perhaps I'm just used to my current workflow ( git push && cap deploy ), but the best I can tell is that after I commit my changes I'm supposed to ssh into the server and run sudo chef-client ? 也许我只是习惯了当前的工作流程( git push && cap deploy ),但我能说的最好的是,在我提交更改后,我应该ssh进入服务器并运行sudo chef-client something about that feels wrong. 有些事情感觉不对。 Is there no cap equivalent, ie chef deploy ? 是否没有相应的上限,即chef deploy

Finally (and perhaps this is a bit more difficult), I'm looking to deploy multiple rails apps to a single server. 最后(也许这有点困难),我希望将多个rails应用程序部署到单个服务器上。 It seems prudent to keep some sort of chef config file in the repo of each app describing the particulars of its deployment, but I'm uncertain how that would then interact with the chef-repo / hosted server. 在每个应用程序的回购中保留某种厨师配置文件以描述其部署的细节似乎是谨慎的,但我不确定那将如何与chef-repo /托管服务器进行交互。 Would each app be a role? 每个应用程序都是一个角色吗? And from my understanding of the way things work, I'm also a little uneasy with the idea that 'chef-client' would be trying to deploy all applications when run. 根据我对事物运作方式的理解,我对'chef-client'试图在运行时部署所有应用程序的想法感到有些不安。 With git push && cap deploy I'm certain of what I'm deploying. 通过git push && cap deploy我确定我正在部署的内容。 Whereas some of the other application repos might not be in a deployable state. 而某些其他应用程序存储库可能不处于可部署状态。 Would there be a way to deploy just a single app in this set up? 是否有办法在此设置中部署一个应用程序?

So knife is actually capable of doing capistrano-esque tasks - specifically, running a command across multiple servers. 因此,刀实际上能够执行capistrano-esque任务 - 特别是在多个服务器上运行命令。

To deploy your app to all of your app servers, assuming you followed the opscode rails application cookbook path, you could just do the following: 要将应用程序部署到所有应用程序服务器,假设您遵循opscode rails应用程序cookbook路径,您可以执行以下操作:

knife ssh role:t<appserver-role> chef-client -xroot -P<pass>

That will run chef-client as root on all of your app servers. 这将在所有应用服务器上以root身份运行chef-client。 It uses chef search API to find all the nodes with that role and run that command on them. 它使用Chef搜索API查找具有该角色的所有节点并在其上运行该命令。

It's pretty powerful. 它非常强大。

I wrote the following article describing how to go about deploying Ruby on Rails using chef. 我写了以下文章,描述了如何使用chef部署Ruby on Rails。

http://tech.hulu.com/blog/2012/07/06/automating-system-provisioning-and-application-deployment-with-chef/ http://tech.hulu.com/blog/2012/07/06/automating-system-provisioning-and-application-deployment-with-chef/

Well... this article is not just about Rails, but the lion share of the example is about deploying Rails. 嗯......这篇文章不只是关于Rails,但是这个例子的最大部分是关于部署Rails。

There is also a community cookbook called "application" cookbook which can be used to deploy Ruby on Rails. 还有一个名为“application”cookbook的社区食谱,可用于部署Ruby on Rails。 Compared to that cookbook, the example in this article should be a little easier to understand for new people. 与该菜谱相比,本文中的示例对于新人来说应该更容易理解。 However, once you get used to doing it using the example in the article, you should definitely look at the application cookbook to see if that makes more sense for you. 但是,一旦您习惯使用本文中的示例,您应该查看应用程序cookbook,看看这对您是否更有意义。

The suggestion about using knife ssh to deploy on demand is absolutely correct. 关于使用刀ssh按需部署的建议绝对正确。 If I could further elaborate on using Chef as a deployment solution (especially compared to tools like Capistrano). 如果我可以进一步详细说明使用Chef作为部署解决方案(特别是与Capistrano等工具相比)。 Chef is designed as a tool for config management and systems integration, part of what that implies is that everything running on a system should be idempotent. Chef被设计为配置管理和系统集成的工具,这意味着系统上运行的所有内容都应该是幂等的。

There's sometimes confusion when using Chef deployment about re-running everything when a Chef run takes place. 在使用Chef部署关于在Chef运行时重新运行所有内容时,有时会出现混乱。 Keep in mind Capistrano works by telling the system "do this", Chef works by telling the system "be this", so what version of an application and what schema a database should be using will normally be defined in attributes and data bags. 请记住,Capistrano通过告诉系统“执行此操作”来工作,Chef通过告诉系统“是这样”来工作,因此应用程序的哪个版本以及数据库应使用的模式通常将在属性和数据包中定义。 When Chef runs if the application is already deployed and the database already has the proper schema nothing should happen, actions should only be taken if the system is not already in the desired state. 当Chef运行时,如果已经部署了应用程序并且数据库已经具有正确的模式,则不应该发生任何事情,只有在系统尚未处于所需状态时才应采取操作。 This is why even when deploying multiple applications re-running everything should not be a problem. 这就是为什么即使在部署多个应用程序时重新运行一切也不应该成为问题。

In my experience, it's better to keep capistrano as it has some RoR functionality that you will have to replicated with Chef. 根据我的经验,最好保留capistrano,因为它具有一些你必须与Chef一起复制的RoR功能。 Chef is a very flexible tool and you can do a lot with it so it can be a replacement for many other tools. Chef是一个非常灵活的工具,你可以用它做很多事情,因此它可以替代许多其他工具。 I personally find targeted tools more helpful. 我个人觉得有针对性的工具更有用。

Capistrano addons for Unicorn, Asset Syncs with S3 and others (like this https://github.com/bokmann/dunce-cap ) are always very useful. Unicorn的Capistrano插件,S3的Asset Syncs和其他设备(如https://github.com/bokmann/dunce-cap )总是非常有用。

As an easier way to deploy and manage Ruby on Rails apps, I can also suggest http://www.cloud66.com 作为部署和管理Ruby on Rails应用程序的一种更简单的方法,我也可以建议http://www.cloud66.com

Disclaimer: I work for Cloud 66. 免责声明:我为Cloud 66工作。

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

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