Thoughts on usage with Librarian-Chef
rosstimson opened this issue · 3 comments
I've just started learning Chef and have tests running fine with minitest-chef-handler however I would also like to use Librarian-Chef (think Bundler for Chef recipes) and I'm unsure of the best place to store my tests due to Librarian discouraging modifying anything in the cookbooks/
directory:
Librarian-Chef takes over your
cookbooks/
directory and manages it for you
based on yourCheffile
. YourCheffile
becomes the authoritative source for
the cookbooks your infrastructure repository depends on. You should not modify
the contents of yourcookbooks/
directory when using Librarian-Chef. If you
have custom cookbooks which are specific to your infrastructure repository,
they should go in yoursite-cookbooks/
directory.
I mirrored my cookbooks/
directory within site-cookbooks/
to store just my tests and this did work fine however it was pointed out to me that this will be depracated http://tickets.opscode.com/browse/CHEF-2308
So this leads me to wondering if there could / should be a dedicated test/
directory (similar to Rails so will be familiar to many) outside of the cookbooks/
directory that is scanned for tests before then looking within the recipes themselves. I'm aware adding the tests could be thought of as forking the recipe and therefore against the use case of Librarian but it seems a shame to lose benefits of Librarian when all I'm doing is testing the recipes worked rather than changing the recipe itself.
Apologies if this is a n00b question and for the length of post; I'm looking forward to hearing thoughts on this.
To be honest, I don't see the problem in having an extra directory into your cookbooks directory, after all they are just files. I've never used librarian, so I guess I'm missing something.
Because you're relying on Librarian to fetch the latest recipes, including dependancies, into your cookbooks/
it will clean out the cookbooks/
directory for tasks such as librarian-chef update
. One of it's main benefits is to provide a cleaner way to use the 'official' recipes without resorting to git submodules which I believe is common place.
This may be more of an issue with Librarian but I cannot think how they could do it any other way. Also, in such circumstances, having the entire cookbooks/
directory under version control seems a lot like version controlling all your bundled / vendored gems that a Rails app depends on kept in your repo along with all your custom code.
The other way this could be done would be that all recipes are supplied with their tests, this is probably more desirable but it would no doubt need a standardised way for doing so.
I'll end up ditching Librarian and just manually keeping / updating cookbooks if I have to, I just thought that it would be nice to have the best of both worlds. I also suspect the testing may come at a much later stage for many learning or starting to use Chef and many may be using Librarian long before looking into testing solutions such as this project (which I'm loving by the way).
Been playing with this stuff a bit more and giving it further thought. Even changing simple attributes, in my case updating the version of Nginx I wish to compile, will cause a similar issue by the looks of it.
I'm therefore resigned to giving up on Librarian for now.