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. Along with my bootstrapping files (deploy.rb and install.rb) I have two config files (solo.json and solo.rb). I've setup my solo.json to run a set of roles and recipes that will setup a web server.
Now I want to use chef-solo to build a mythtv box with my own customisations. Instead of having solo.json should I have 'web_server.json' and 'mythtv.json' to list my different recipes/roles 开发者_开发问答for creating these servers?
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);
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. Such as apache2 which I want on both Mythtv & my web server.
I have poured over the docs and the few chef-solo tutorials and here is what I came up with. Like nearly all programs there is more that one way to do it (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. Then create a role for your myth machine and put it in the roles folder. When you create a new role just edit the base.json and add the role to the run list.
Also, I don't see a site-cookbooks folder. 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. Say you want edit an apache2 template, you would put it in site-cookbooks-->apache2-->templates-->default-->apache2.conf.erb (for example). 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. If you don't call the recipe/role from json then it won't be executed. Within my chef-solo repo, to create my tarball, I run:
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. Both are big parts of the client-server setup and I did not think they would ever get added to chef-solo. Chef-solo FTW!
My bootstrap fwiw. https://github.com/tripleonard/chef-solo-bootstrap
Cheers!
精彩评论