简体   繁体   English

我应该有多个Chef-solo json配置文件吗?

[英]Should I have multiple chef-solo json config files?

I've just started using chef-solo. 我刚刚开始使用厨师独奏。 I've started using chef-solo to build my Ruby on Rails web servers from scratch. 我已经开始使用Chef-solo从头开始构建Ruby on Rails Web服务器。 Along with my bootstrapping files (deploy.rb and install.rb) I have two config files (solo.json and solo.rb). 除了我的引导文件(deploy.rb和install.rb),我还有两个配置文件(solo.json和solo.rb)。 I've setup my solo.json to run a set of roles and recipes that will setup a web server. 我已经将solo.json设置为运行一组将设置Web服务器的角色和配方。

Now I want to use chef-solo to build a mythtv box with my own customisations. 现在,我想使用Chef-solo来构建具有自己的自定义的mythtv框。 Instead of having solo.json should I have 'web_server.json' and 'mythtv.json' to list my different recipes/roles for creating these servers? 我应该拥有“ web_server.json”和“ mythtv.json”来列出创建这些服务器的不同配方/角色,而不是拥有solo.json?

Logically it should work but is there a better way? 从逻辑上讲应该可以,但是有更好的方法吗? / is this the correct way? /这是正确的方法吗?

Here is my full setup so far (as it stands it builds a web server for Ruby on Rails); 到目前为止,这是我的完整设置(按现状,它可以为Ruby on Rails构建Web服务器);

https://github.com/map7/chef-solo https://github.com/map7/chef-solo

One way would be to copy my whole chef-solo directory and customise it for creating my Mythtv box, but then I have to maintain two sets of chef-solo bootstrappings and config files and some of the cookbooks will be used in both situations. 一种方法是复制我的整个Chef-solo目录并对其进行自定义,以创建Mythtv框,但是然后我必须维护两组Chef-solo引导程序和配置文件,并且某些食谱将在两种情况下都使用。 Such as apache2 which I want on both Mythtv & my web server. 例如我要在Mythtv和Web服务器上使用的apache2。

I have poured over the docs and the few chef-solo tutorials and here is what I came up with. 我已经阅读了文档和一些chef-solo教程,这就是我想出的。 Like nearly all programs there is more that one way to do it (TIMTOWTDI). 像几乎所有程序一样,有多种方法可以做到这一点(TIMTOWTDI)。 I am thinking of doing my own tutorial... 我正在考虑做自己的教程...

Create a base.json as your primary configuration options: users accounts, maybe iptables with access to ssh only, sudo for your user, etc. Things that would be the same on both (all) machines. 创建一个base.json作为您的主要配置选项:用户帐户,也许是仅可访问ssh的iptables,您的用户的sudo等。在这两个(所有)计算机上,情况都是相同的。 Then create a role for your myth machine and put it in the roles folder. 然后为您的神话机器创建一个角色,并将其放置在roles文件夹中。 When you create a new role just edit the base.json and add the role to the run list. 创建新角色时,只需编辑base.json并将角色添加到运行列表。

Also, I don't see a site-cookbooks folder. 另外,我没有看到site-cookbooks文件夹。 I was unclear on this when I started with chef-solo too. 当我也开始主厨-个展时,我对此还不清楚。 You need this. 需要这个。 If you alter a cookbook (which you will eventually) you place the altered file in site-cookbooks folder, in the same directory structure as the original cookbook. 如果更改了食谱(最终将要更改),则将更改后的文件放置在site-cookbooks文件夹中,该文件夹与原始食谱位于相同的目录结构中。 Say you want edit an apache2 template, you would put it in site-cookbooks-->apache2-->templates-->default-->apache2.conf.erb (for example). 假设您要编辑apache2模板,可以将其放在site-cookbooks-> apache2-> templates-> default-> apache2.conf.erb中(例如)。 At runtime chef will look to your template instead of the original. 在运行时,厨师将查看您的模板,而不是原始模板。 This makes it easy to track your additions/changes and also allows for easy upgrade of original cookbook. 这样可以轻松跟踪您的添加/更改,还可以轻松升级原始食谱。 So, you will only ever have one cookbook tarball. 因此,您将永远只有一个食谱tarball。 If you don't call the recipe/role from json then it won't be executed. 如果您不从json调用配方/角色,则不会执行。 Within my chef-solo repo, to create my tarball, I run: 在我的主厨-个库中,创建我的tarball,运行:

tar zcvf chef-solo.tar.gz ./cookbooks ./roles ./site-cookbooks ./data-bags

Last note, later versions of chef-solo have gotten some love with ability to use data-bags and a cookbook has been created to allow for search. 最后要注意的是,chef-solo的更高版本对使用数据袋的能力颇有好感,并且已创建了食谱以供搜索。 Both are big parts of the client-server setup and I did not think they would ever get added to chef-solo. 两者都是客户端服务器设置的重要组成部分,我认为它们永远不会添加到Chef-solo中。 Chef-solo FTW! 厨师独奏FTW!

My bootstrap fwiw. 我的引导者走了。 https://github.com/tripleonard/chef-solo-bootstrap https://github.com/tripleonard/chef-solo-bootstrap

Cheers! 干杯!

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

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