简体   繁体   English

AWS,OpsWorks和Chef依赖项:最干净的解决方案是什么?

[英]AWS, OpsWorks and Chef dependencies: what's the cleanest solution?

I've got a Chef project that, locally with Vagrant, works really nicely. 我有一个Chef项目,在Vagrant本地工作得非常好。 I'm using librarian-chef , which means I can specify my dependencies in a Cheffile like this: 我正在使用librarian-chef ,这意味着我可以像这样在Cheffile指定依赖项:

site 'http://community.opscode.com/api/v1'
cookbook 'jenkins'

When I then run librarian-chef install , it pulls down jenkins and all the cookbooks it depends on into a cookbooks directory. 然后,当我运行librarian-chef install ,它会将jenkins及其依赖的所有菜谱下拉到一个cookbooks目录中。

There's also another directory, site-cookbooks , which is where I'm writing all of my own custom cookbooks and recipes. 还有另一个目录, site-cookbooks ,这是我编写自己的所有自定义食谱和食谱的地方。

In the Vagrantfile , you can then tell it to look at two different paths for cookbooks: Vagrantfile ,您可以告诉它查看食谱的两种不同路径:

config.vm.provision "chef_solo" do |chef|
  chef.cookbooks_path = ["cookbooks", "site-cookbooks"]
  # snip
end

This works perfectly when I run vagrant up . 当我vagrant up时,这效果很好。 However, it doesn't seem to play nicely with AWS OpsWorks – as this requires all cookbooks to be at the top level of the Chef repository. 但是,它似乎无法与AWS OpsWorks很好地配合-因为这要求所有食谱都在Chef存储库的顶层。

My question then, is: what's the nicest way to use Chef with OpsWorks without including all of the dependencies at the top level of my repository? 那么我的问题是:在不将存储库顶层的所有依赖项包括在内的情况下,将Chef与OpsWorks结合使用的最佳方法是什么?

OpsWorks doesn't play nice with a number of tools created for Chef. OpsWorks在为Chef创建的许多工具中表现不佳。 I tried using it not long after it came out and gave up on it (OpsWorks was using Chef 9 at the time). 我尝试使用它不久后就放弃了(OpsWorks当时使用的是Chef 9)。

I suggest you either move from OpsWorks to Enterprise Chef, or try the following: 建议您从OpsWorks迁移到Enterprise Chef,或尝试以下操作:

1. Create a separate repo for your cookbooks 1.为您的食谱创建一个单独的仓库

Keep all cookbooks in a separate repo. 将所有食谱保存在单独的存储库中。 If you want it a part of a larger repository, you can include it as git submodule . 如果您希望它成为更大的存储库的一部分,则可以将其作为git submodule包括在内。 Git submodules are generally a bad thing but cookbooks are a separate entity, that can live independently of the rest of your project, so it actually works quite well in this case. Git子模块通常是一件坏事,但是菜谱是一个单独的实体,可以独立于项目的其余部分而生存,因此在这种情况下,它确实运行良好。

To add a cookbooks repository inside another repo, use: 要将菜谱库添加到另一个仓库中,请使用:

git submodule add git://github.com/my/cookbooks.git ./cookbooks

2. Keep your cookbooks together with community cookbooks 2.将您的食谱与社区食谱一起保存

You can either clone the cookbooks into your repository, add them as submodules, or try using librarian-chef/Berkshelf to manage them. 您可以将食谱复制到存储库中,将其添加为子模块,也可以尝试使用librarian-chef / Berkshelf进行管理。 You could try using this method, it should work with librarian-chef: https://sethvargo.com/using-amazon-opsworks-with-berkshelf/ 您可以尝试使用此方法,它应该与图书管理员兼职: https : //sethvargo.com/using-amazon-opsworks-with-berkshelf/

从最近开始, OpsWorks支持Chef 11.10和Berkshelf ,为您提供了一种更好的管理菜谱依赖关系的方法。

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

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