0

I don't want to use Chef Server as for now, but rather want to leverage Chef Solo. I need to keep configs (attributes and files) of particular servers in a separate Git repo. This is needed to keep cookbooks in an open repo while hiding configs in a private repo.

Is there a built-in possibility in Chef to get attributes and files from Git repo? How do you usually fetch them?

1 Answers1

0

Look into using Berfshelf and the environment cookbook pattern. This design pattern puts all cookbooks in their own repos, public or private.

Specifically, for the configuration of particular servers, you can use a cookbook in a private repo with a recipe using node.set as mentioned in that blog post. Or set attributes in the attributes/default.rb with a statement like default['foobar']['version'] = '1.2.3'. The open repo cookbooks that are not private can be berksified and run from the private cookbooks with include_recipe "{open-cookbook}::{open-recipe}".

I have used this design patter before in combination with knife-solo, especially since Berkshelf support was added in 0.4.x. Specifically, I use the command knife solo cook someuser@localhost --sync-only. This will prepare the kitchen for installation on a target machine (download all berksified cookbooks, create solo.rb, etc. etc.) but not actually run the code. Or invoke as knife solo cook someuser@targetnode to prepare, sync and run chef-solo on the target node.

dialt0ne
  • 3,027
  • 17
  • 27
  • Thanks! I've seen that Berkshelf is going away (at least it's not going to work with Vagrant), is there a way that will work for both Vagrant & usual Server? – Stanislav Bashkyrtsev Jun 12 '14 at 10:33
  • Berkshelf is definitely not going away, it's just the vagrant-berkshelf plugin. I think your options are either to use [test-kitchen](http://kitchen.ci/) (the [named successor](https://sethvargo.com/the-future-of-vagrant-berkshelf/) to vagrant-berkshelf plugin) or take chef_solo out of your Vagrantfile and just use knife solo with something like `knife solo cook vagrant@localhost --ssh-port 2222` (i haven't tested this). – dialt0ne Jun 12 '14 at 17:32