sample-infrastructure-repo
sample-infrastructure-repo copied to clipboard
[WIP] Try using plain vagrant-berkshelf instead of vagrant-toplevel-cookbooks (alternative approach)
This PR tries to achieve the same as #4, namely replacing the need for vagrant-toplevel-cookbooks by using a plain vagrant-berkshelf solution.
In contrast to #4, the approach here is to use separate Berksfiles per VM rather than a single Berksfile with groups:
- using
config.berkshelf.path = "Berksfile.<name>"to define disjoint Berksfiles - defining one Berksfile per VM
It seems to work quite well in the first experiments. Notes:
- it creates a separate .lock file for each Berksfile -- so there's no potential conflict here as with using the groups feature
- (!) you need to delete the .lock file when updating the cookbook version via the tag ref.
rm Berksfile.app_v1.lock && vagrant provision app_v1works :+1:
Still, even if that works, there's some reason for vagrant-toplevel-cookbooks though:
- not cluttering your project with so many Berksfiles
- no need to remove the .lock files before updating a version
- programmability from within the Vagrantfile
Last one could be achieved by having a function or "mini-plugin" in the .vagrant_plugins file as well, but that would have to be created per-project. So having a globally installed vagrant plugin makes sense as well.